Python Forum
Convert Vba Primes to Python Primes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert Vba Primes to Python Primes
#1
codeNUMBEROFPRIMES = 100
NUMBEROFPRIMESPERLINE = 10
count = 0
number = 2
while (count < NUMBEROFPRIMES):
    isPrime = True
    divisor = int
    divisor = 2
    
    for divisor in range(2,int(number/2)):
        If (number % divisor) == 0
        isPrime = False 
        break
        if isPrime:
         count = count + 1
         print(number)
         if (count % NUMBEROFPRIMESPERLINE) == 0:
             print(number/n)
        number = number + 1           
what is wrong with code?
Reply
#2
for divisor in range(2,int(number/2)):
first time fails, range (2, 1)

also NUMBEROFPRIMES is not defined, codeNUMBEROFPRIMES is
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help to identify Mersenne Primes, I do need a search pattern. Pleiades 0 1,927 Dec-03-2019, 11:05 PM
Last Post: Pleiades
  Sophie Germain Primes PythonLamer 7 5,623 Oct-28-2017, 05:27 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020