Almost the polar opposite if this challenge, and I suspect it will be slightly easier.
Your task is to take two integers in the format a/b
(Forming a rational number) then output the number in decimal exactly.
For example, if you were to input 1/3
, it would output:
0.33333333333333333
And would keep on printing 3s until the end of time, with an optional leading 0. (You could also print one character per line if and only if your language does not allow printing on the same line.)
The behaviour for x/0
will be undefined. For a number that looks like it doesn't repeat (Like, say 5/4
) it actually does repeat. Either of the following two forms would be acceptable for 5/4
:
1.25000000000000000
1.24999999999999999
(The same with whole numbers, 1.9999999
or 2.000000
)
The fraction may not be in its simplest form, and a
or b
may be negative (Note -a/b = -(a/b)
, -a/-b = a/b
, a/-b = -a/b
, and -.6249999
is invalid, but -0.6249999
is acceptable, but you still can use.
bc
, or is that cheating? \$\endgroup\$a
and/orb
be negative? \$\endgroup\$a
orb
(or both) can be negative) \$\endgroup\$