You have a for loop nested in a while loop in order to find prime numbers. The proper way is to set the flag to false before starting the for loop that checks for factors. Inside the for loop, set the flag to true when a factor is found. After the for loop terminates, check the value of the flag. If it is still false, no factors were found and the number is prime.
Correct Answer:
Verified
Q23: Which of the following questions should you
Q24: In the do/while loop, the loop condition
Q25: Using an if statement to validate input
Q26: Before the loop begins, if you know
Q27: If you want to loop between the
Q29: while loops can be nested.
Q30: for loops can be nested.
Q31: Which Java class enables us to read
Q32: How many times will a loop with
Q33: How many times will a loop with
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents