Hi programmers!
I want to write in c++ please,help me to solve this problem
Problem: Raja Beta is bad at maths, his teacher always complaints about him.Help him in his prime numbers homework.
Input: Two space separated positive integer m and n
Output: Print all prime numbers p such that m <= p <= n, one number per line
Constraints: 1 <= m <= n <= 1000000000
Sample Input: 1 10
Sample Output:
2
3
5
7
Here's some code to get you started. It's inefficient, but it seems that you haven't coded something like this before, so it's best to start basic and slowly optimise it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
bool is_prime( int n )
{
// code for algorithm here
}
int main()
{
int m = 0, n = 0;
// get user input
for( int i = m; i <= n; i++ ) {
if( is_prime( i ) )
std::cout << i << '\n';
}
}