So I need some help figuring out how to do this, this was the prompt given:
Write a program that accepts an input integer n, and calculates the number and sum of all the numbers between 1 and n (inclusive) that are NOT evenly divisible by ANY of the first 5 prime numbers (2,3,5,7,11). The program should print out a clearly labeled count and sum.
I understand how to have a cout and cin for an integer n, and I understand the form of mod how you do 5 % 4 = 1, but I'm not sure how to do the part after (inclusive).
I have to use a while statement and I was thinking of using if statements as well.
The % returns the remainder, so if you have a zero remainder, then you have an even divisor. (The number fits perfectly with nothing left over.)
If you check to make sure that the counter is not evenly divisible by 2, 3, 5, 7, and 11 (as in the remainder is not equal to zero, which means it is not evenly divisible), you can the add that counter to your ongoing sum. Then you should increment the counter by 1 and continue on checking and adding until your number reaches the n that was inputted by the user.