1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
% problem 3 solve:- write('600851475143 = '), div_mod0(600851475143,2), !. div_mod0(1,_):- !, write('1'). div_mod0(BaseNum,DivNum):- BaseNum mod DivNum =:= 0, Divided is BaseNum / DivNum, DivNum1 is 2, write(DivNum),write(' * '), div_mod0(Divided,DivNum1). div_mod0(BaseNum,DivNum):- DivNum1 is DivNum + 1, div_mod0(BaseNum,DivNum1). |
実行結果:
1 2 3 4 5 |
1 ?- time(solve). ***********************(解答伏せます)********************** % 18,489 inferences, 0.016 CPU in 0.016 seconds (100% CPU, 1183296 Lips) true. |