a little addition missing in my program

the question was
find a number that:(y is the number)
y%2=1
y%3=1
y%4=1
y%5=1
y%6=1
y%7=0

this is what i wrote :

#include "stdafx.h"
#include "iostream"
using namespace std;
int main()
{
int y=0,e, x=0;
while(x==0)
{
y=y+7 ;
int n=2 ;
x=1;
while (n<=6 && x==1)
{
if ( y%n!=1 )
x=0;
else
n++ ;
}
}

cout << "the total is " << y << endl;
cin >> e ;
system("pause");
return 0;
}

the program runs and no problem, y= 301
but the instructor then asked for the number after 301 which is also %2=%3====1 and %7=0
i cant find a way so my program says
the first number is
the second number is
the third number is
..
.
.
.
Thanks for helping !
Topic archived. No new replies allowed.