Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Babbage-problem/Prolog/babbage-problem-1.pro
Normal file
13
Task/Babbage-problem/Prolog/babbage-problem-1.pro
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
:- use_module(library(clpfd)).
|
||||
|
||||
babbage_(B, B, Sq) :-
|
||||
B * B #= Sq,
|
||||
number_chars(Sq, R),
|
||||
append(_, ['2','6','9','6','9','6'], R).
|
||||
babbage_(B, R, Sq) :-
|
||||
N #= B + 1,
|
||||
babbage_(N, R, Sq).
|
||||
|
||||
babbage :-
|
||||
once(babbage_(1, Num, Square)),
|
||||
format('lowest number is ~p which squared becomes ~p~n', [Num, Square]).
|
||||
7
Task/Babbage-problem/Prolog/babbage-problem-2.pro
Normal file
7
Task/Babbage-problem/Prolog/babbage-problem-2.pro
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
babbage :-
|
||||
Start is ceil(sqrt(269696)),
|
||||
between(Start, inf, N),
|
||||
Square is N * N,
|
||||
Square mod 100 =:= 96, % speed up
|
||||
Square mod 1000000 =:= 269696,!, % break after first true
|
||||
format('lowest number is ~d which squared becomes ~d~n', [N, Square]).
|
||||
Loading…
Add table
Add a link
Reference in a new issue