Easy program not working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
int main()
{
    int n, nr, nrfin;
    cout << "Introduceti numarul natural n.\n";
    cin>>nr;
    cout << "Introduceti un numar natural.\n";
    cin>>n;
    while (n%1==0 || n%3==0 || n%5==0 || n%7==0 || n%9==0)
    {
        if (n>=0)
        {
            if (nr>=0)
            {
                if(n<nr&&n%3==0)
            {
                nrfin++;
            }
            }
            else
            {
                return 0;
            }
        }
        else
        {
            return 0;
        }
    cin >>n;
    }
    cout <<nrfin;
    return 0;
}


Basically I want my program to keep inputting a number (nr) greater than or equal to 0, then keep inputting numbers until an even number is inputted, at which point it needs to sort out all the numbers inputted and print the ones that are less than nr and are divisible by 3.


It's not working.
the
n%3==0

alone should be sufficient enough to keep any other odd number out of your formula.
Topic archived. No new replies allowed.