Question
Write a program that finds and prints all of the prime numbers between 2 and N (N is input from the user). Your program should
Write a program that finds and prints all of the prime numbers between 2 and N (N is input from the user). Your program should also print the amount of prime numbers between 2 and N. For example, if N = 10 your program should print something like follows: There are 4 prime numbers between 2 and 10: 2, 3, 5, 7 To solve this problem use a doubly nested loop (a loop inside another loop). The outer loop can iterate from 2 to N while the inner loop checks to see if the current counter value for the outer loop is prime. To calculate whether number n is prime the program must loop from 2 to n-1 and if any of these numbers evenly divides n, then n cannot be prime. If none of the values from 2 to n-1 evenly divides n, then n must be prime. Note: You cannot use any "break statements for this program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started