University of Lethbridge - Mathematics & Computer Science

Problem #20 Reciprocals

The reciprocal of a positive integer is 1 divided by that integer. For example, the reciprocal of 37 is 1/37. When the division is carried out to evaluate a reciprocal in decimal form, the result often turns out to be an infinitely repeating decimal. For example, 1/37 = 0.0270270270... where the group of digits 027 repeats infinitely.

The input to your program, recip.dat, will contain a list of such positive integers, one per line, as shown in the following example:
2
100
6250000
204800000000000000
8470329472543003390683225006796419620513916015625

For the input shown above, the output is the following:

Program 20 by team 0

1 / 2 =
0.5

1 / 100 =
0.01

1 / 6250000 =
0.00000016

1 / 204800000000000000 =
0.0000000000000000048828125

1 / 8470329472543003390683225006796419620513916015625 =
0.0000000000000000000000000000000000000000000000001180591620717411303424
End of program 20 by team 0

Original problem: Rocky Mountain Region ACM contest, 1999