Magic constant: Difference between revisions
Added 11l
Alextretyak (talk | contribs) m (Small fix of Python output) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 41:
=={{header|11l}}==
{{trans|Python}}
<syntaxhighlight lang="11l">
F a(=n)
n += 2
R n * (n ^ 2 + 1) / 2
F inv_a(x)
V k = 0
L k * (k ^ 2.0 + 1) / 2 + 2 < x
k++
R k
print(‘The first 20 magic constants are:’)
L(n) 1..19
print(Int(a(n)), end' ‘ ’)
print("\nThe 1,000th magic constant is: "Int(a(1000)))
L(e) 1..19
print(‘10^’e‘: ’inv_a(10.0 ^ e))
</syntaxhighlight>
{{out}}
<pre>
The first 20 magic constants are:
15 34 65 111 175 260 369 505 671 870 1105 1379 1695 2056 2465 2925 3439 4010 4641
The 1,000th magic constant is: 503006505
10^1: 3
10^2: 6
10^3: 13
10^4: 28
10^5: 59
10^6: 126
10^7: 272
10^8: 585
10^9: 1260
10^10: 2715
10^11: 5849
10^12: 12600
10^13: 27145
10^14: 58481
10^15: 125993
10^16: 271442
10^17: 584804
10^18: 1259922
10^19: 2714418
</pre>
=={{header|ALGOL 68}}==
|