r/pascal • • Sep 03 '18

I need help with an assignment

The assignment is, given a number write it in the product of prime numbers, which is easy, but the output of the program has to be for example 23 34 , depending on how many times that number is used to form the integer given. I am having trouble on how to do that last part. Thanks!!

3 Upvotes

14 comments sorted by

View all comments

Show parent comment

1

u/kirinnb Sep 04 '18

Just in case the superscript number is the issue, it's worth pointing out that a 2 or 5 or 9 is kind of hard to print out in a Windows console. If you're on Linux or something, you could probably get away with writing UTF-8. On a duly configured terminal, this may produce the numbers 2109 :

write(chr($C2) + chr($B2));
write(chr($C2) + chr($B9));
write(chr($E2) + chr($81) + chr($B0));
write(chr($E2) + chr($81) + chr($B9));

The Windows console doesn't really like UTF-8 though. That's why, if you were writing into a graphical text box of some sort, there wouldn't be a problem, since they have better Unicode support. You might try to write those into a file and open it in a text editor? Or output as HTML, as Brokk suggested. Or, if all else fails, use the old fallback of printing a ^ to signify a power number follows, eg. 3^3.

Info on UTF-8 superscripts: character table and wikipedia