Advertisement
hav0koriginal

Prime check

Oct 19th, 2023 (edited)
1,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import math
  2.  
  3.  
  4. start_num = int(input("Adja meg az elso szamot: "))
  5. end_num = int(input("Adja meg az utolso szamot: "))
  6. sum_of_all = 0
  7.  
  8. if start_num == 1:
  9.     start_num += 1
  10.  
  11. for analyzed_num in range(start_num,end_num):
  12.     analyzed_num_divisible = False
  13.     for divider_num in range(2,int(math.sqrt(analyzed_num)) + 1):
  14.         if analyzed_num % divider_num == 0:
  15.             analyzed_num_divisible = True
  16.     if analyzed_num_divisible == False:
  17.         print("prime:",analyzed_num)
  18.         sum_of_all += analyzed_num
  19.  
  20. print(f"Prim szamok osszege: {sum_of_all}")
  21.        
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement