Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- #include <list>
- #include <cstdlib>
- using namespace std;
- //const int TOP = 1000001;
- inline
- bool is_prime (int x)
- {
- for (int i = 2; i <= sqrt (x); i++) {
- if (x % i == 0) return false;
- }
- return true;
- }
- int main (int argc, char* argv[])
- {
- //list <int> primes_bag(2);
- //list <int>::iterator last = primes_bag.first ();
- int top = atoi (argv[1]);
- for (int i = 2; i < top; i++) {
- //if (is_prime (i)) primes_bag.push (i);
- if (is_prime (i)) cout << i << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment