$\frac{199319989756262759279209}{5} $ = $ 3.9864\times 10^{22}$
according to Mathematica, but I would like to see this number exactly in decimal form (not in scientific notation). I'm attempting to use the Euclidean Algorithm and Extended Euclidean algorithm to get a final result, and precision and accuracy both are very much needed. This number truncated would give me x and then y is simply the difference of that large number and 5 x. Unless there's an easier way to do the Euclidean algorithm in Mathematica as well that'd be nice.

but I would like to see this number exactly in decimal form (not in scientific notation) You can use AccountingForm? n1 = 199319989756262759279209; AccountingForm[N[n1/5, 30], {30, 29}] gives 39863997951252551855841.8000000 (just remember, this is only a wrapper.
–
NasserOct 15 '13 at 5:12

@m_goldberg ah I was writing that in an answer when you commented. I think it is good to have an "official" answer though.
–
Jacob AkkerboomOct 15 '13 at 11:07

I overlooked this function for a long time and now suddenly I saw it because it was an option for the autocomplete. I have very often used Mod and Quotient together, being a little frustrated that basically the same computation was being done twice. I learned something today :)
–
Jacob AkkerboomOct 15 '13 at 11:10

Though I guess finding the remainder by simply subtracting the quotient from the original number is not inefficient at all.
–
Jacob AkkerboomOct 15 '13 at 11:15

2 Answers
2

is not the same as the question in the body, which asks for an exact decimal representation of

199319989756262759279209 / 5

Regarding the first question, there are integers, x, y, that make 199319989756262759279209 = 5x + y true. This will be true for any integer divisor, not just 5. It follows from the division identity (or division algorithm): given positive integers A, B, there exist non-negative integers Q, R, where R < B, such that A = BQ + R.

Regarding the second question, if we accept a convention, such as a vinculum or ellipsis, for expressing the repeating "tail" of a decimal number, then we can express any fraction exactly as a decimal number. In the worst case scenario, the magnitude of the "non-integer part" of the quotient may require as many as B-1 places, so the decimal expression is always finite, given that the divisor, B, is finite. (The decimal expression with vinculum stands for a non-terminating decimal, however. The case of a repeating zero is dealt with inconsistently.)

The Euclidean algorithm seems like overkill for this case. The operations needed to calculate this have been well optimized and your computer probably has hardware to do such divisions. See wiki:division algorithm for a glimpse of what algorithms are actually used.

Restorable numbers

In reply to comments by DavidCarraher below, I have to add the warning that just storing the x and y is not enough information to restore the result of the fraction. You also need to store the number you divided by. Here are two solutions

Also, we should remember that in Mathematica. we can write {x, y} = QuotientRemainder[199319989756262759279209, 5]
–
m_goldbergOct 15 '13 at 11:11

Careful. The quotient plus remainder does not uniquely determine a number. Consider this: QuotientRemainder[9,4] = {2,1}. QuotientRemainder[15,7] = {2,1}. But 9/4 does not equal 15/7. We might alternatively say that the QuotientRemainder function is a one-to-many mapping and hence not invertible.
–
David CarraherOct 15 '13 at 11:16

@DavidCarraher I do not think the OP asked for this. From the notation 39863997951252551855841.8000000 the original number can also not be reconstructed, unless of course you know we have divided by 5 (which is also enough information to reconstruct the number from the quotient and the remainder).
–
Jacob AkkerboomOct 15 '13 at 11:22

I was referring to your answer, which is not a useful representation of the rational number expressed through the given fraction. (Btw, the original number can be reconstructed from the decimal if it is made clear, typically by a vinculum or an ellipsis, that the zero repeats ad infinitum.)
–
David CarraherOct 15 '13 at 11:39

@DavidCarraher ahh, I see what you mean now. Indeed it is a pitfall to think that the rational number could be reproduced from this, good point. I will edit
–
Jacob AkkerboomOct 15 '13 at 11:48

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.