I don't know anything about programming but I would like to figure out how to program this idea I had for calculating prime numbers. I know that this looks a little bit jumbled, but logically it should work.

My basic idea is that the square root of the first number that cannot be divided by 2 evenly that is not a prime number, is the next prime number. Therefore, if you were to work it out then you would come up with 9 who's square root is 3 which is the next prime number after two. Then you would find the first number after 9 that cannot be divided by 2 and 3, which would be 25 who's square root is 5 which is the next prime number after 3. And the program would hopefully be able to continue this progression infinitely without taking up all of the ram while outputting its findings to a simple text document. Any help would be appreciated.

Thank you

y1=2, y2=3, y3=5, and so on yn=the next prime number

the square root of x equals yn

x is the first non prime number that cannot be divided evenly by y1 or y2 or ...yn

loop adding yn as a divisor to each loop

output each y to text document append document for each yn

create new program for each loop

first loop will create program2

second loop will create program3

then the loops will alternate between program 2 and 3

the only difference between the programs are how many y's are being divided

the creation of the programs are in order to save ram so the y's are static and not held in memory

append programs 2 and 3 each time instead of creating new program