Odd and square numbers

From Rosetta Code
Revision as of 11:57, 23 November 2021 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: <br> Find odd and square numbers under '''1.000''' =={{header|Python}}== <lang python> szamok=[] i=1 limit = 1000 for i in range(limit): num = i*i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Odd and square numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task


Find odd and square numbers under 1.000

Python

<lang python> szamok=[] i=1 limit = 1000

for i in range(limit):

   num = i*i
   if (num < 1000 and num > 99 and (num % 2 == 1)):
       szamok.append(num)

print(szamok) </lang>

Output:
[121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961]