Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generate Prime Numbers [Python]
#1
Code:
num1 = #this is checked for primeness(or primeily, or primeilyness)
                   looper = 3                                                                           #sets vars
                   trigger = 0
                   num2 = 0
                   while trigger == 0:
                          
                           remain = num1%looper                    
                           if remain != 0:                                                                      #if remain = 0 then num1 is divisable by looper
                                   if looper == num1 - 1:
                                           if num1 == 4:                                                #4 breaks it(maybe)
                                                   meow = 0
          
                                           else:
                                                   num2 = num2 + 1                      
                                                   print num1                                                   #if num1 is printed then it is prime
                                                   trigger = 1
                                   looper = looper + 1
                                  
                           else:
                                   print "not prime"    
                                   trigger = 1

VictoireVictoireVictoire
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 2,043 09-30-2019, 12:59 AM
Last Post: samsmith001
  Simple Python Python Compiler Canoris 21 9,351 06-01-2011, 06:30 PM
Last Post: Filefinder
  Python 2 vs 3? Jake 8 2,721 12-11-2010, 04:13 PM
Last Post: Bursihido
  Convert numbers to a certain base uber1337 2 1,305 04-06-2010, 11:48 AM
Last Post: uber1337
  Python help Kharnage 2 925 02-12-2010, 09:07 PM
Last Post: Kharnage

Forum Jump:


Users browsing this thread: 1 Guest(s)