I'm trying to write a program that prints out all prime numbers from 1 to 300. It isn't working the way I want it to. Right now it appears to have caused an infinite loop. Here is my code.
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
for(int i=0; i<=300; i++){
for(int j=2; j<300; j++){
if(i%j!=0){
cout<<j <<endl;
}
}
}
}