Cullen and Woodall numbers: Difference between revisions
Content deleted Content added
Drkameleon (talk | contribs) Added Arturo implementation |
→{{header|Lua}}: added Lua solution |
||
Line 422: | Line 422: | ||
[2, 3, 6, 30, 75, 81, 115, 123, 249, 362, 384, 462] |
[2, 3, 6, 30, 75, 81, 115, 123, 249, 362, 384, 462] |
||
</pre> |
</pre> |
||
=={{header|Lua}}== |
|||
<lang lua>function T(t) return setmetatable(t, {__index=table}) end |
|||
table.range = function(t,n) local s=T{} for i=1,n do s[i]=i end return s end |
|||
table.map = function(t,f) local s=T{} for i=1,#t do s[i]=f(t[i]) end return s end |
|||
function cullen(n) return (n<<n)+1 end |
|||
print("First 20 Cullen numbers:") |
|||
print(T{}:range(20):map(cullen):concat(" ")) |
|||
function woodall(n) return (n<<n)-1 end |
|||
print("First 20 Woodall numbers:") |
|||
print(T{}:range(20):map(woodall):concat(" "))</lang> |
|||
{{out}} |
|||
<pre>First 20 Cullen numbers: |
|||
3 9 25 65 161 385 897 2049 4609 10241 22529 49153 106497 229377 491521 1048577 2228225 4718593 9961473 20971521 |
|||
First 20 Woodall numbers: |
|||
1 7 23 63 159 383 895 2047 4607 10239 22527 49151 106495 229375 491519 1048575 2228223 4718591 9961471 20971519</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |