Originally Posted by
Danny123
@ Norm. Yes i did not think about a design before writing the code, it is something I need to start doing. I have written the logical list of steps:
1: Loop through some numbers up to a certain limit ( in this case I put it as 10 )
2: Find all of the Factors of the current number in the loop
3: Determine that if the only factors of that number are 1 and the current number, display that number.
The array was used to hold the current factors of the number. The newCounter loop was designed to loop through the array elements, and add them to the newFactor variable. If newFactor variable was equal to 1, plus the number itself, then it is a prime number and must be printed. Does this make sense?
@ Parranoia. If I understand you correctly, my loop should look like this.
for (int counter = 1; counter < number.(sqrt function here); counter++)