python - Next Prime Number Generation -


I am trying to write a program that creates consecutive and prominent numbers, then you start it, Numbers are saved in a text file or as a string. So far I've got this code, but it does not know how to work continuously. Def primenumbers (): j = 2 chk = 1 f = open ("primes.txt", "w") primes = [] notprimes = [] Ask = input ("how many primes ? ") While len (primes) & lt; Int (ask): k = 2 while not (k == j) and not (j% k == 0): k = k + 1 if k == j: primes.append (j) f.write (str ( J) + "\ n") Other: notprimes.append (j) if lane (primes)> gt; = 1000 * chk: chk = chk + 1 print ("" + str (primes) "+" "primes.txt", "+ str (primes)" files written in "written" file F.close return ("")

In your script, add it below ( Indent not)

  if __name__ == '__main__': while (true): primenumbers ()  

the function is being called

Useful Links:


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -