Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Calkin-Wilf-sequence/11l/calkin-wilf-sequence.11l
Normal file
23
Task/Calkin-Wilf-sequence/11l/calkin-wilf-sequence.11l
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
T CalkinWilf
|
||||
n = 1
|
||||
d = 1
|
||||
|
||||
F ()()
|
||||
V r = (.n, .d)
|
||||
.n = 2 * (.n I/ .d) * .d + .d - .n
|
||||
swap(&.n, &.d)
|
||||
R r
|
||||
|
||||
print(‘The first 20 terms of the Calkwin-Wilf sequence are:’)
|
||||
V cw = CalkinWilf()
|
||||
[String] seq
|
||||
L 20
|
||||
V (n, d) = cw()
|
||||
seq.append(I d == 1 {String(n)} E n‘/’d)
|
||||
print(seq.join(‘, ’))
|
||||
|
||||
cw = CalkinWilf()
|
||||
V index = 1
|
||||
L cw() != (83116, 51639)
|
||||
index++
|
||||
print("\nThe element 83116/51639 is at position "index‘ in the sequence.’)
|
||||
Loading…
Add table
Add a link
Reference in a new issue