Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Prime generator

Name: Anonymous 2012-01-06 11:59

#include <iostream>
using namespace std;

///////World's smallest prime number generator (u jelly? u mirin? lol deal with it homo)
int main() {
    int count,n = 0;
    cout << "\t>that feel when prime number generator\n\nEnter the number at which you want to stop checking primes--go!\n";
    cin >> n;
    cout << "\n\n";
    for(int i=2;i<=n;++i) {
        for(int b=2;b<i;++b) {
            if((i%b)==0 && i!=b) ++count;
        }
        if(count==0) cout << i << " is a prime\n";
        count=0;
    }
    return 0;
}

Name: Anonymous 2012-01-06 15:22

>>11
You're not very good at trolling are you?

>>12
For autistics like you:


(defun prime (n i)
  (if (= (mod n i) 0)
    (return-from prime -1)
    (if (< i (round (sqrt n)))
      (prime n (+ i 1))
      (return-from prime n))))

(defun primes (l h)
  (if (> (prime l) 0) (print l))
  (if (< l h) (primes (+ l 1) h)))

(primes 1 100)

1
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
NIL

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List