I'm new to programming and i wanted to initiate a program that will find prime numbers to a certain extent.
so i wrote this:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int x = 0;
for (int i = 1; i < 1000000; i++)
{
for (int j = 1; j <= i; j++)
{
if (i / j*j == i)
x++;
}
if (x == 1 || x == 2)
cout << i;
}
int p;
cin >> p;
return 0;
}
but it only prints me "1" and that's it.
what did i do wrong?