Odd and square numbers: Difference between revisions
→Python: short alternative
(Added Vala) |
(→Python: short alternative) |
||
Line 956:
<syntaxhighlight lang="python">
import math
szamok = []
limit = 1000
for i in range(1,
num = i*i
if (
szamok.append(num)
Line 970:
[121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961]
</pre>
;By using itertools
<syntaxhighlight lang="python">from itertools import accumulate, count, dropwhile, takewhile
print(*takewhile(lambda x: x<1000, dropwhile(lambda x: x<100, accumulate(count(8, 8), initial=1))))</syntaxhighlight>
{{out}}
<pre>121 169 225 289 361 441 529 625 729 841 961</pre>
=={{header|Quackery}}==
|