Problem #8

Fractions to Decimals
Public 7y:10м 3xp Programming 38.7%

Write a program that will accept a fraction of the form N/D, where N is the numerator and D is the denominator, that prints out the decimal representation. If the decimal representation has a repeating sequence of digits, it should be indicated by enclosing it in brackets. For example, 1/3 = .33333333...is denoted as .(3), and 41/333 = .123123123...is denoted as .(123).

Typical conversions are:

1/3 = .(3)
22/5 = 4.4
1/7 = .(142857)
3/8 = .375
45/56 = .803(571428)

Sample Run

ENTER N,D : 1,7

1/7 = .(142857)


What is the answer for the fraction 11/59?
Source:1993 USACO Qualifying Round




You need to be a member to keep track of your progress.
Register


Time may end, but hope will last forever.

Other Challenge Sites

Contact

elasolova
[64][103][109][97][105][108][46][99][111][109]