Quote (Elements_Fury @ Dec 5 2014 08:17pm)
K soo, 1 quick question, after the variable j cycle, what do i put into it to check all of the numbers and decide to print the primes because i feel like i am missing a full step in that area, like i am testing for 1 number then moving on when i should be doing multiple tests per number
So if I were to write out the quick logic for this program:
Input number x
y = floor(sqrt(x))
loop i from 1 to x
loop k from 2 to y
if k >= i - 1 then too high, exit k loop (a number mod itself is 0 so we can't run this comparison)
if i mod k = 0 then use boolean to false, exit k loop
else still prime, nothing changes
next k
if boolean still true, print i, else nothing (set boolean back to true)
next i
Then you may have to force a few prime numbers @ the lower ends that you know are prime (1, 2, 3)
e/ Made a few mistakes, edited version should be fine afaik.
So you basically have your prime test numbers (i) 1->x and your test integers (k) 2->y, you compare your prime test number with all test integers up to (but not including) k to see if it can come up with an even division
This post was edited by Dontrunaway on Dec 5 2014 08:45pm