c
This commit is contained in:
commit
0216f4584a
17
main.py
Normal file
17
main.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
def program():
|
||||
print("2. feladat: Tökéletes számok")
|
||||
hatar = int(input("A keresés felső határa: "))
|
||||
osszes = []
|
||||
for x in range(1, hatar+1):
|
||||
osszes.append(x)
|
||||
tokszam = []
|
||||
for x in osszes:
|
||||
osztok = []
|
||||
for y in osszes:
|
||||
if x % y == 0 and y < x:
|
||||
osztok.append(y)
|
||||
if sum(osztok) == x:
|
||||
tokszam.append(x)
|
||||
print("A megadott határig talált tökéletes számok: ", tokszam)
|
||||
program()
|
||||
program()
|
Loading…
Reference in New Issue
Block a user