29 lines
844 B
Text
29 lines
844 B
Text
$ include "seed7_05.s7i";
|
|
include "bigrat.s7i";
|
|
|
|
const proc: fractran (in var bigInteger: number, in array bigRational: program) is func
|
|
local
|
|
var integer: index is 1;
|
|
var bigRational: newNumber is 0_/1_;
|
|
begin
|
|
while index <= length(program) do
|
|
newNumber := rat(number) * program[index];
|
|
if newNumber = rat(trunc(newNumber)) then
|
|
number := trunc(newNumber);
|
|
if 2_ ** ord(log2(number)) = number then
|
|
writeln(log2(number));
|
|
end if;
|
|
index := 1;
|
|
else
|
|
incr(index);
|
|
end if;
|
|
end while;
|
|
end func;
|
|
|
|
const proc: main is func
|
|
local
|
|
const array bigRational: program is []
|
|
(17_/91_, 78_/85_, 19_/51_, 23_/38_, 29_/33_, 77_/29_, 95_/23_, 77_/19_, 1_/17_, 11_/13_, 13_/11_, 15_/14_, 15_/2_, 55_/1_);
|
|
begin
|
|
fractran(2_, program);
|
|
end func;
|