Van Eck sequence: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (add MIranda) |
|||
Line 2,137: | Line 2,137: | ||
<pre>{0,0,1,0,2,0,2,2,1,6} |
<pre>{0,0,1,0,2,0,2,2,1,6} |
||
{4,7,30,25,67,225,488,0,10,136}</pre> |
{4,7,30,25,67,225,488,0,10,136}</pre> |
||
=={{header|Miranda}}== |
|||
<syntaxhighlight lang="miranda">main :: [sys_message] |
|||
main = [ Stdout (show list ++ "\n") |
|||
| list <- [take 10 eck, take 10 (drop 990 eck)] |
|||
] |
|||
eck :: [num] |
|||
eck = 0 : map item [1..] |
|||
where item n = find last (tl sofar) |
|||
where sofar = reverse (take n eck) |
|||
last = hd sofar |
|||
find :: *->[*]->num |
|||
find i = find' 1 |
|||
where find' n [] = 0 |
|||
find' n (a:as) = n, if a = i |
|||
= find' (n+1) as, otherwise</syntaxhighlight> |
|||
{{out}} |
|||
<pre>[0,0,1,0,2,0,2,2,1,6] |
|||
[4,7,30,25,67,225,488,0,10,136] |
|||
</pre> |
|||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |
||
Line 2,172: | Line 2,194: | ||
<pre> 0 0 1 0 2 0 2 2 1 6 |
<pre> 0 0 1 0 2 0 2 2 1 6 |
||
4 7 30 25 67 225 488 0 10 136</pre> |
4 7 30 25 67 225 488 0 10 136</pre> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
<syntaxhighlight lang="nim">const max = 1000 |
<syntaxhighlight lang="nim">const max = 1000 |