First 9 prime Fibonacci number: Difference between revisions
Content deleted Content added
Hellangelx (talk | contribs) |
Alextretyak (talk | contribs) Added 11l |
||
Line 3:
;Task:
<br>Show on this page the first 9 prime Fibonacci numbers.
=={{header|11l}}==
{{trans|Python}}
<syntaxhighlight lang="11l">
F prime(x)
I x < 2
R 0B
I x == 2 | x == 3
R 1B
I x % 2 == 0
R 0B
L(i) (3 .. Int(sqrt(x))).step(2)
I x % i == 0
R 0B
R 1B
V n = 11
V fibn = 3
V (a, b) = (Int64(1), Int64(1))
L n > 0
(a, b) = (b, a + b)
I prime(b)
print(‘fib(#.): #.’.format(fibn, b))
n--
fibn++
</syntaxhighlight>
{{out}}
<pre>
fib(3): 2
fib(4): 3
fib(5): 5
fib(7): 13
fib(11): 89
fib(13): 233
fib(17): 1597
fib(23): 28657
fib(29): 514229
fib(43): 433494437
fib(47): 2971215073
</pre>
=={{header|Ada}}==
|