Hofstadter-Conway $10,000 sequence: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
 
(One intermediate revision by one other user not shown)
Line 1,224:
Max in [2^18, 2^19]: 0.534645
Max in [2^19, 2^20]: 0.533779</pre>
 
=={{header|EasyLang}}==
{{trans|Go}}
<syntaxhighlight>
numfmt 4 0
a[] = [ 1 1 ]
x = 1
n = 2
mallow = 0
for p = 1 to 19
max = 0
nextPot = n * 2
while n < nextPot
n = len a[] + 1
x = a[x] + a[n - x]
a[] &= x
f = x / n
max = higher max f
if f >= 0.55
mallow = n
.
.
print "max between 2^" & p & " and 2^" & p + 1 & " was " & max
.
print "winning number " & mallow
</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 3,861 ⟶ 3,887:
 
a rd 1 shl 20</syntaxhighlight>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">int A(1 + 1<<20), N, Power2, WinningN;
real Max, Member;
[A(1):= 1; A(2):= 1;
N:= 3; Power2:= 2; Max:= 0.;
Text(0, " Range Maximum^m^j");
Format(1, 6);
repeat A(N):= A(A(N-1)) + A(N-A(N-1));
Member:= float(A(N)) / float(N);
if Member >= Max then Max:= Member;
if Member >= 0.55 then WinningN:= N;
if N & 1<<Power2 then
[Text(0, "2^^"); IntOut(0, Power2-1);
Text(0, " to 2^^"); IntOut(0, Power2);
ChOut(0, 9\tab\);
RlOut(0, Max);
CrLf(0);
Power2:= Power2+1;
Max:= 0.;
];
N:= N+1;
until N > 1<<20;
IntOut(0, WinningN);
Text(0, " is the winning position.^m^j");
]</syntaxhighlight>
{{out}}
<pre>
Range Maximum
2^1 to 2^2 0.666667
2^2 to 2^3 0.666667
2^3 to 2^4 0.636364
2^4 to 2^5 0.608696
2^5 to 2^6 0.590909
2^6 to 2^7 0.576087
2^7 to 2^8 0.567416
2^8 to 2^9 0.559459
2^9 to 2^10 0.554937
2^10 to 2^11 0.550101
2^11 to 2^12 0.547463
2^12 to 2^13 0.544145
2^13 to 2^14 0.542443
2^14 to 2^15 0.540071
2^15 to 2^16 0.538784
2^16 to 2^17 0.537044
2^17 to 2^18 0.536020
2^18 to 2^19 0.534645
2^19 to 2^20 0.533779
1489 is the winning position.
</pre>
 
=={{header|zkl}}==
1,983

edits