Calkin-Wilf sequence: Difference between revisions

m
Added Easylang
(Add PARI/GP implementation)
m (Added Easylang)
Line 526:
83116/51639 is the 123456789th term of the sequence.
</pre>
=={{header|EasyLang}}==
[https://easylang.online/show/#cod= Run it]
{{trans|Nim}}
<syntaxhighlight>
subr first
n = 1 ; d = 1
.
proc next . .
n = 2 * (n div d) * d + d - n
swap n d
.
print "The first 20 terms of the Calkwin-Wilf sequence are:"
first
for i to 20
write n & "/" & d & " "
next
.
print ""
#
first
i = 1
while n <> 83116 or d <> 51639
next
i += 1
.
print i
print "83116/51639 is at position " & i
</syntaxhighlight>
{{out}}
<pre>
The first 20 terms of the Calkwin-Wilf sequence are:
1/1 1/2 2/1 1/3 3/2 2/3 3/1 1/4 4/3 3/5 5/2 2/5 5/3 3/4 4/1 1/5 5/4 4/7 7/3 3/8
123456789
83116/51639 is at position 123456789
</pre>
 
=={{header|EDSAC order code}}==
===Find first n terms===
Line 753 ⟶ 789:
83116/51639 IS AT 123456789
</pre>
 
=={{header|F_Sharp|F#}}==
===The Function===
1,982

edits