Program | FRACTION.C, FRACTION.CPP, FRACTION.PAS |
Let b0, b1, b2,...,
bn be integers with bk >
0 for k > 0. The continued fraction of order n with coeficients
b1, b2,..., bn
and the initial term b0 is defined by the following expression
which can be abbreviated as [b0;b1,...,
bn].
Write a program that determines the expansion of a given rational number as
a continued fraction. To ensure uniqueness, make bn
> 1.
Input
The input consists of an undetermined number of rational numbers. Each rational
number is defined by two integers, numerator and denominator.
Output
For each rational number given in the input, you should output the corresponding
continued fraction.
Sample Input
43 19
1 2
Sample Output
[2;3,1,4]
[0;2]