Jump to content

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,int( math.ceil(math.sqrtisqrt(limit - 1))) + 1, 2):
num = i*i
if (num < 1000 and num > 99):
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}}==
559

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.