From 0216f4584aee1220e8e47042327d37ad63ec0e71 Mon Sep 17 00:00:00 2001 From: medojanos Date: Fri, 17 Jan 2025 12:14:06 +0100 Subject: [PATCH] c --- main.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..de563f3 --- /dev/null +++ b/main.py @@ -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() \ No newline at end of file