Prime Numbers
Code:
// www.cppfuzz.com (Ahmad Mukhtar) /* ______ .______ .______ _______ __ __ ________ ________ / || _ \ | _ \ | ____|| | | | | / | / | ,----'| |_) | | |_) | | |__ | | | | `---/ / `---/ / | | | ___/ | ___/ | __| | | | | / / / / | `----.| | | | | | | `--' | / /----. / /----. \______|| _| | _| |__| \______/ /________| /________| */ #include <iostream> using namespace std; void main() { int num; cout << "Enter a number: "; cin >> num; cout << "Prime numbers less than " << num << " are: " << endl; for (int i=2;i<num;i++) { for (int j=2;j<=i;j++) { if (j<i) { if ((i%j)==0) break; } else { cout << i << "\t"; } } } cout << endl; }