Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Fusc-sequence/Sidef/fusc-sequence.sidef
Normal file
20
Task/Fusc-sequence/Sidef/fusc-sequence.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
func fusc(n) is cached {
|
||||
|
||||
return 0 if n.is_zero
|
||||
return 1 if n.is_one
|
||||
|
||||
n.is_even ? fusc(n/2) : (fusc((n-1)/2) + fusc(((n-1)/2)+1))
|
||||
}
|
||||
|
||||
say ("First 61 terms of the Stern-Brocot sequence: ", 61.of(fusc).join(' '))
|
||||
|
||||
say "\nIndex and value for first term longer than any previous:"
|
||||
printf("%15s : %s\n", "Index", "Value");
|
||||
|
||||
var (index=0, len=0)
|
||||
|
||||
5.times {
|
||||
index = (index..Inf -> first_by { fusc(_).len > len })
|
||||
len = fusc(index).len
|
||||
printf("%15s : %s\n", index.commify, fusc(index).commify)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue