informaticage

Inefficient primes list in range

May 2nd, 2021
657
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. upper_bound = int(input("Upperbound: "))
  2.  
  3. for num in range(2, upper_bound + 1):
  4.     # Controlliamo se num è primo
  5.     divisors_amount = 0
  6.     for divisor in range(2, num):
  7.         if(num % divisor == 0):
  8.             # Se sono qui anche solo una volta allora non ho un numero primo
  9.             divisors_amount = divisors_amount + 1
  10.  
  11.     # Dopo aver controllato tutti i divisori
  12.     # Se ne ho trovati 0 allora ho un numero primo
  13.     if(divisors_amount > 0):
  14.         print(num)
  15.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×