Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Left-factorials/Prolog/left-factorials.pro
Normal file
22
Task/Left-factorials/Prolog/left-factorials.pro
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
leftfact(N):-
|
||||
leftfact(N, 0, 0, 1).
|
||||
|
||||
leftfact(N, N, _, _):-
|
||||
!.
|
||||
leftfact(N, M, L, F):-
|
||||
((M =< 10 ; (M =< 110, 0 is M mod 10)) ->
|
||||
writef("!%w = %w\n", [M, L])
|
||||
;
|
||||
(0 is M mod 1000 ->
|
||||
number_string(L, S),
|
||||
string_length(S, Len),
|
||||
writef("length of !%w is %w\n", [M, Len])
|
||||
;
|
||||
true)),
|
||||
L1 is L + F,
|
||||
M1 is M + 1,
|
||||
F1 is F * M1,
|
||||
leftfact(N, M1, L1, F1).
|
||||
|
||||
main:-
|
||||
leftfact(10001).
|
||||
Loading…
Add table
Add a link
Reference in a new issue