Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Fusc-sequence/Picat/fusc-sequence.picat
Normal file
29
Task/Fusc-sequence/Picat/fusc-sequence.picat
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
main =>
|
||||
println("First 61 fusc numbers:"),
|
||||
println([fusc(I) : I in 0..60]),
|
||||
nl,
|
||||
println("Points in the sequence whose length is greater than any previous fusc number length:\n"),
|
||||
println(" Index fusc Len"),
|
||||
largest_fusc_string(20_000_000).
|
||||
|
||||
table
|
||||
fusc(0) = 0.
|
||||
fusc(1) = 1.
|
||||
fusc(N) = fusc(N//2), even(N) => true.
|
||||
fusc(N) = fusc((N-1)//2) + fusc((N+1)//2) => true.
|
||||
|
||||
largest_fusc_string(Limit) =>
|
||||
largest_fusc_string(0,Limit,0).
|
||||
|
||||
largest_fusc_string(Limit,Limit,_).
|
||||
largest_fusc_string(N,Limit,LargestLen) :-
|
||||
N <= Limit,
|
||||
F = fusc(N),
|
||||
Len = F.to_string.len,
|
||||
(Len > LargestLen ->
|
||||
printf("%8d %8d %4d\n",N,F,Len),
|
||||
LargestLen1 = Len
|
||||
;
|
||||
LargestLen1 = LargestLen
|
||||
),
|
||||
largest_fusc_string(N+1,Limit,LargestLen1).
|
||||
Loading…
Add table
Add a link
Reference in a new issue