First 100 Prime Nos.
1
Name:
C++
2009-08-10 6:32
I'm trying to make a program which displays the first 100 prime numbers. I've managed to make one which tells us whether a number is prime or not(
http://pastebin.com/m38992e3e ), but I cannot figure out how to print the first 100 prime nos.
Any help?
………………………………………………„–~~*¯:::::::::::::::::;;;;;;;;;;;;;""lll|||||||||||||||||||||||||||||||||||||||||¡¡„
…………………………………………...„-";;;;;;;;::::::::::::::::::::;;;;;;;;;;;¡¡¡¡||||||||||||||||||||||||||||||||||||||||||||||||||¡¡„_
………………………………………....,/;;;;;;;;;;;;;;_„„––~~"**¯¯¯¯¯***"lll||||||||||||||||||||||||||||||||||||||||||||||||||||||||l„„„_
……………………………………….../;;;;;;;„–~'*¯ . . . . . . . . . : : : : ::::"lllll||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡„
………………………………………,/;;;;;„-". . . . . . . . . . . . . . . : : : : ::::::"llll|||||||||||||||||||||||||||||||||||||||||||||||||||||¡„
………………………………........./;;;„-" . . . . . . . . . . . . . . . . . . : : : : :::::"lll||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………….|';;;/' . . . . . . . . . . . . . . . . . . . . . : : : ::::::'lll|||||||||||||||||||||||||||||||||||||||||||||||||||||¡„
………………………………….../;;;/ . . . . . . . . . . . . . . . . . . . . . . . : : : ::::::'ll||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………../'„-" . . . . . . . . . . . . . . . . . . . . . . . . : : : ::::::l|||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………./-". . . . . . . . . . . . . . . . . . . . . . . . . . . : : ::::::|||||||||||||||||||||||||||||||||||||||||||||||||||||||¡
…………………………………. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .: : ::::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .: ::::„¡|||||||||||||||||||||||||||||||||||||||||||||||||||||lllllll¡
…………………………………. . . . . . . . . . . . . . . . . . . . . . . . . . . . .: ::::„¡¡||||||||||||||||||||||||||||||||||||||||||||||||||||||lllllllll|
…………………………………. . . . . . . .*~¡¡¡¡„„__ . . . . . . . . . . . . : :::„¡||||||||||||||||||||||||||||||||||||||||||||||llllllllll
…………………………………. . . . . . . . ;;;l||||||||||||||||||¡¡¡¡„_________„„¡¡¡¡¡|||||||||||||||||||||||||||||||||||||||||||||||||||l|||||l|l
…………………………………. . . ' . . . .„~*¯"ll||||||||||||||||||||||||¡¡„ : : ¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡
……………………………......|¡ . . . . _„/':::_„-~**¯¯¯¯**"ll|||||||||) . l|||¡¡|||||||||||llll"""¯¯¯"""l||||||||||||||||||||||||||||||||||||||||¡
……………………………......|| . . . . ""|:::::¯"*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡||||l . |l . . l||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l'
……………………………......l| . . . . . .', . . . .:::'l||||||||||||||ll" .,' . . :¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l'
…………………………………. . . . . . . .' , . . . . . . „¡¡¡l" . ., ' . . ::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l'
………………………………….. . . . . . . . . . . ."'l¡¡lll" . .„–" . . .:::l|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'
…………………………………... . . . . . . . . . . . . . . ' ¯ . . . . .::::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l
……………………………………. . . . . . . . . . . . . . . „¡|l . . . . :::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„„_
…………………………………_„„¡¡:::::. . . . . . . . . . .„¡||l' . 'l¡, .::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„_
…………………………._„¡¡¡||||||||||||:::::: . . . . . . . . . ¡||l„-~|¡|¡|¡|¡l¡¡¡¡l¡l¡l¡l¡l¡l¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„_
.........................._„„¡¡||||||||||||||||||||||||¡„::::. . . . . . . .,¡l/;;;l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„_
………….._„„„¡¡¡¡|||||||||||||||||||||||||||||||||||||¡;:::. . . . . . .„-";;;;¡l¡l¡l¡l¡l¡l¡|||lll|||¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
_„„„¡¡¡¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡„:::. . . . „-";;;¡l¡l¡l¡l¡l¡l¡l¡l¡l¡||||||||||||¡l¡l¡l¡l¡|||¡¡l¡l¡l¡l¡l¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡;::. .„/';;;¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡|||||||||||||||¡l¡l¡l||||||||||||¡l¡l¡l|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡„::/;;;;¡l¡l¡l¡l¡¡l|||||lllllllllllllllllll||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡|;;¡l¡l¡l¡l¡""""". . . . . . . :::|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡l¡l¡;;;;;¡¡¡¡„: . . . . . . :::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡„ . . . ::::::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||lll"::'"ll¡¡¡¡||||¡¡¡¡¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡;;;;;„¡¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||""""""""lll|||||||""""""""|||||||||l""""l||||||||||"'"""""""'ll||||||""""""""""'|||""""""""""'||""""""""""""'|'"""'||||||||"'""||||ll""¯¯¯¯""l||||||||||||||||||||||||||
|||||||||||||||||||||||||| . .¡¡¡¡¡¡„„. ."l|||||||. . |||||||||||l' . . .'l||||||||| . .¡¡¡¡¡„ . .'||||| . . ¡¡¡¡¡¡¡¡|||¡¡¡ . .¡¡¡¡¡¡¡¡¡¡¡||¡¡¡¡¡¡¡ . .¡¡¡|||¡¡|| . .|||||||||. . '||||' . „¡¡|||||¡¡„„„'|||||||||||||||||||||||||
|||||||||||||||||||||||||| . .|||||||||¡ . .l||||||. . |||||||||l. . ¡|¡. .'l||||||| . .""" . -l|||||| . . """"""||||| . .""""""'||||||||| . .|||||||||| . .|||||||||. . '||||¡„„ . ¯"*lll||||||||||||||||||||||||||||
|||||||||||||||||||||||||| . .||||||||l' . ,||||||| . .'|||||||l . ."""' . .'l|||||. . |||||||¡ . "||| . . ||||||||||||||| . .|||||||||||||||||||| . .|||||||||| . .'|||||||| . .||||||||||||l|¡¡¡„ . .'|||||||||||||||||||||||||
|||||||||||||||||||||||||| . ."""'. „„¡¡||||||"' . . '"'||l' . .¡|||||||¡ . .'|||| . ."""" . „¡|||| . . """"""'|||| . .'""""""||||||||| . .|||||||||||¡„ . '""" . „¡|||||_¯"""¯ _„„¡|||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
Name:
Anonymous
2009-08-10 6:43
take 10 $ sieve [2..]
where sieve (n:ns) = n : sieve [k | k <- ns, mod k n /= 0]
4
Name:
Anonymous
2009-08-10 6:46
………………………………………………„–~~*¯:::::::::::::::::;;;;;;;;;;;;;""lll|||||||||||||||||||||||||||||||||||||||||¡¡„
…………………………………………...„-";;;;;;;;::::::::::::::::::::;;;;;;;;;;;¡¡¡¡||||||||||||||||||||||||||||||||||||||||||||||||||¡¡„_
………………………………………....,/;;;;;;;;;;;;;;_„„––~~"**¯¯¯¯¯***"lll||||||||||||||||||||||||||||||||||||||||||||||||||||||||l„„„_
……………………………………….../;;;;;;;„–~'*¯ . . . . . . . . . : : : : ::::"lllll||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡„
………………………………………,/;;;;;„-". . . . . . . . . . . . . . . : : : : ::::::"llll|||||||||||||||||||||||||||||||||||||||||||||||||||||¡„
………………………………........./;;;„-" . . . . . . . . . . . . . . . . . . : : : : :::::"lll||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………….|';;;/' . . . . . . . . . . . . . . . . . . . . . : : : ::::::'lll|||||||||||||||||||||||||||||||||||||||||||||||||||||¡„
………………………………….../;;;/ . . . . . . . . . . . . . . . . . . . . . . . : : : ::::::'ll||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………../'„-" . . . . . . . . . . . . . . . . . . . . . . . . : : : ::::::l|||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………./-". . . . . . . . . . . . . . . . . . . . . . . . . . . : : ::::::|||||||||||||||||||||||||||||||||||||||||||||||||||||||¡
…………………………………. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .: : ::::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…………………………………. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .: ::::„¡|||||||||||||||||||||||||||||||||||||||||||||||||||||lllllll¡
…………………………………. . . . . . . . . . . . . . . . . . . . . . . . . . . . .: ::::„¡¡||||||||||||||||||||||||||||||||||||||||||||||||||||||lllllllll|
…………………………………. . . . . . . .*~¡¡¡¡„„__ . . . . . . . . . . . . : :::„¡||||||||||||||||||||||||||||||||||||||||||||||llllllllll
…………………………………. . . . . . . . ;;;l||||||||||||||||||¡¡¡¡„_________„„¡¡¡¡¡|||||||||||||||||||||||||||||||||||||||||||||||||||l|||||l|l
…………………………………. . . ' . . . .„~*¯"ll||||||||||||||||||||||||¡¡„ : : ¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡
……………………………......|¡ . . . . _„/':::_„-~**¯¯¯¯**"ll|||||||||) . l|||¡¡|||||||||||llll"""¯¯¯"""l||||||||||||||||||||||||||||||||||||||||¡
……………………………......|| . . . . ""|:::::¯"*¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡||||l . |l . . l||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l'
……………………………......l| . . . . . .', . . . .:::'l||||||||||||||ll" .,' . . :¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l'
…………………………………. . . . . . . .' , . . . . . . „¡¡¡l" . ., ' . . ::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l'
………………………………….. . . . . . . . . . . ."'l¡¡lll" . .„–" . . .:::l|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'
…………………………………... . . . . . . . . . . . . . . ' ¯ . . . . .::::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||l
……………………………………. . . . . . . . . . . . . . . „¡|l . . . . :::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„„_
…………………………………_„„¡¡:::::. . . . . . . . . . .„¡||l' . 'l¡, .::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„_
…………………………._„¡¡¡||||||||||||:::::: . . . . . . . . . ¡||l„-~|¡|¡|¡|¡l¡¡¡¡l¡l¡l¡l¡l¡l¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„_
.........................._„„¡¡||||||||||||||||||||||||¡„::::. . . . . . . .,¡l/;;;l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡¡„„_
………….._„„„¡¡¡¡|||||||||||||||||||||||||||||||||||||¡;:::. . . . . . .„-";;;;¡l¡l¡l¡l¡l¡l¡|||lll|||¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
_„„„¡¡¡¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡„:::. . . . „-";;;¡l¡l¡l¡l¡l¡l¡l¡l¡l¡||||||||||||¡l¡l¡l¡l¡|||¡¡l¡l¡l¡l¡l¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡;::. .„/';;;¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡l¡|||||||||||||||¡l¡l¡l||||||||||||¡l¡l¡l|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡„::/;;;;¡l¡l¡l¡l¡¡l|||||lllllllllllllllllll||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡|;;¡l¡l¡l¡l¡""""". . . . . . . :::|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡l¡l¡;;;;;¡¡¡¡„: . . . . . . :::||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡„ . . . ::::::¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||lll"::'"ll¡¡¡¡||||¡¡¡¡¡||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||¡¡;;;;;„¡¡|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||""""""""lll|||||||""""""""|||||||||l""""l||||||||||"'"""""""'ll||||||""""""""""'|||""""""""""'||""""""""""""'|'"""'||||||||"'""||||ll""¯¯¯¯""l||||||||||||||||||||||||||
|||||||||||||||||||||||||| . .¡¡¡¡¡¡„„. ."l|||||||. . |||||||||||l' . . .'l||||||||| . .¡¡¡¡¡„ . .'||||| . . ¡¡¡¡¡¡¡¡|||¡¡¡ . .¡¡¡¡¡¡¡¡¡¡¡||¡¡¡¡¡¡¡ . .¡¡¡|||¡¡|| . .|||||||||. . '||||' . „¡¡|||||¡¡„„„'|||||||||||||||||||||||||
|||||||||||||||||||||||||| . .|||||||||¡ . .l||||||. . |||||||||l. . ¡|¡. .'l||||||| . .""" . -l|||||| . . """"""||||| . .""""""'||||||||| . .|||||||||| . .|||||||||. . '||||¡„„ . ¯"*lll||||||||||||||||||||||||||||
|||||||||||||||||||||||||| . .||||||||l' . ,||||||| . .'|||||||l . ."""' . .'l|||||. . |||||||¡ . "||| . . ||||||||||||||| . .|||||||||||||||||||| . .|||||||||| . .'|||||||| . .||||||||||||l|¡¡¡„ . .'|||||||||||||||||||||||||
|||||||||||||||||||||||||| . ."""'. „„¡¡||||||"' . . '"'||l' . .¡|||||||¡ . .'|||| . ."""" . „¡|||| . . """"""'|||| . .'""""""||||||||| . .|||||||||||¡„ . '""" . „¡|||||_¯"""¯ _„„¡|||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5
Name:
Anonymous
2009-08-10 6:46
6
Name:
Anonymous
2009-08-10 7:15
>>1
1st 100 prime #'s
I have further Americanised the thread title for you, ingrate.
7
Name:
Anonymous
2009-08-10 8:20
/* 100firstprimes.cpp
Copyright (c) 2009 >>7
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
For God so loved the world, that he gave his only begotten Son, that
whosoever believeth in him should not perish, but have everlasting
life. (John 3:16, King James Bible)
Neither the name "100firstprimes" nor the names of its developers may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <iostream.h>
main()
{
cout << "2\n3\n5\n7\n11\n13\n17\n19\n23\n29\n31\n37\n41\n43\n47\n53\n59\n61\n67\n71\n73\n79\n83\n89\n97\n101\n103\n107\n109\n113\n127\n131\n137\n139\n149\n151\n157\n163\n167\n173\n179\n181\n191\n193\n197\n199\n211\n223\n227\n229\n233\n239\n241\n251\n257\n263\n269\n271\n277\n281\n283\n293\n307\n311\n313\n317\n331\n337\n347\n349\n353\n359\n367\n373\n379\n383\n389\n397\n401\n409\n419\n421\n431\n433\n439\n443\n449\n457\n461\n463\n467\n479\n487\n491\n499\n503\n509\n521\n523\n541\n";
return 0;
}
8
Name:
Anonymous
2009-08-10 8:45
9
Name:
Anonymous
2009-08-10 8:49
>>8
What's the third divisor?
10
Name:
Anonymous
2009-08-10 9:00
Hello OP,
I think the right answer here is a good reading of the SICP, but since most newbies that come for help to
/prog/ ignore such helpful advice, I'll give you a full answer:
Take a look at this article:
http://www.mactech.com/articles/mactech/Vol.05/05.10/LazyLists/index.html
The interesting part for you (after you've read the whole article), should be:
(defun sieve (lazy-list)
(lazy-cons
(lazy-car lazy-list)
(sieve (filter
#'(lambda (x) (not (divisiblep x (lazy-car lazy-list))))
(lazy-cdr lazy-list)))))
(defconstant primes (sieve (lazy-cdr integers)))
This shows a very simple implementation of a lazy prime sieve.
I wrote this function to take the first n values from a lazy list:
(defun take (n lazy-list)
(labels ((take-rec (n ll acc)
(if (= n 0)
acc
(take-rec (1- n)
(lazy-cdr ll)
(cons (lazy-car ll) acc)))))
(nreverse (take-rec n lazy-list nil))))
Here's the code that would take the first 100 primes:
(take 100 primes)
and the result:
(2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191
193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283
293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401
409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509
521 523 541)
11
Name:
Anonymous
2009-08-10 9:01
>>8
It is, go learn math.
prime: a number that has no factor but itself and 1.
12
Name:
Anonymous
2009-08-10 9:10
2 isn't a prime, all even numbers are composite (one divisor is, second is 1, third is itself).
13
Name:
Anonymous
2009-08-10 9:12
* (one divisor is 2, second is 1, third is itself).
14
Name:
Anonymous
2009-08-10 9:14
15
Name:
Anonymous
2009-08-10 9:22
>>13
* (one divisor is 2 , second is 1, third is itself ).
16
Name:
Anonymous
2009-08-10 9:26
17
Name:
Anonymous
2009-08-10 9:28
>>15
Yeah, two different twos. One is because it's
itself , the id.2, another because of the even-number rule, the divide-all-evens-2.
18
Name:
Anonymous
2009-08-10 9:34
19
Name:
Anonymous
2009-08-10 9:44
>>8
I would like to hear FV‘s stance on that
20
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
!frozEn/KIg
2009-08-10 9:51
Okay, you're wasting my time:
1 is a prime(no divisors), every number after 1 is prime if it:
1.Has its only divisors 1 and itself: result:
1,2,3,5,7,11,13...
_____________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
You're supposed to be developing verbal abilities for your big aptitude test tomorrow.
21
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
!frozEn/KIg
2009-08-10 9:51
( i'm trying to benchmark various canvas libraries right now)
___________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
To interpret laws is almost always to corrupt them.
22
Name:
Anonymous
2009-08-10 9:56
>>20
1 isn't a prime, by the usual definition of a prime number, as it only has one divisor(itself). Prime numbers require having 2 divisors (1 and the actual number, those two should be distinct), however 1 isn't a composite number. Think of 1 as a number which isn't prime and isn't composite, it's a more special element, called an identity element, such as 1 * n == n * 1. Look it up in wikipedia, which you so much treasure.
23
Name:
Anonymous
2009-08-10 9:56
24
Name:
23
2009-08-10 9:57
>>22
I was planning to say what you have said in three posts, exactly that. Thanks for sparing me the horror of talking to Void.
25
Name:
Anonymous
2009-08-10 9:58
2 isn't prime?
I lol'd
26
Name:
Anonymous
2009-08-10 9:59
erm, 1 * n == n * 1 == n
27
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
!frozEn/KIg
2009-08-10 10:02
>>22 Ah, Mathfags changed the definition of prime to prop their shitty theories.
http://en.wikipedia.org/wiki/Primality#Primality_of_one
"The change in label occurred so that the fundamental theorem of arithmetic, as stated, is valid, i.e., “each number has a unique factorization into primes."
_____________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible.
28
Name:
Anonymous
2009-08-10 10:04
Mathfags
Hehe. Mr. Void, a frequent visitor to /b/ and an avid reader of ED.
29
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
!frozEn/KIg
2009-08-10 10:06
>>28 http://en.wikipedia.org/wiki/Ad_hominem
__________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
The trouble with the rat race is that even if you win, you're still a rat.
30
Name:
Anonymous
2009-08-10 10:13
>>29
Wrong. I just found it humourous that such a high-brow being would visit such filthy places. But I guess your grammar is on a par with /b/'s standard.
31
Name:
Anonymous
2009-08-10 10:31
>>29
you're a fucking moron.
you do realise that you have quoted ED many many times, and admitted to visiting /b/ & /r9k/ frequently.
32
Name:
Anonymous
2009-08-10 10:39
>>31
you're a fucking moron.
you do realise that you please try to ignore troll posts.
33
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
!frozEn/KIg
2009-08-10 10:44
>>31 http://www.encyclopediadramatica.com/index.php/Butthurt
__________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
Bureaucracy destroys initiative. There is little that bureaucrats hate more than innovation, especially innovation that produces better results than the old routines. Improvements always make those at the top of the heap look inept.
34
Name:
Anonymous
2009-08-10 10:47
>>33
mind explaining how this is even close to related?
or maybe you're currently feeling this? i don't understand
35
Name:
Anonymous
2009-08-10 10:49
>>32,33
Guys stop talking to invisible posts.
36
Name:
Anonymous
2009-08-10 10:52
What escapes me, Void, is how are you so enamoured with ED, yet you scorn /prog/ 's memes.
37
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
2009-08-10 10:55
>>36
it is because the memes generated from /b/ are much more intelligent than the completely brainless /prog/tard memes such as spouting SEPPLES all the time and reading books
__________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
Bureaucracy destroys initiative. There is little that bureaucrats hate more than innovation, especially innovation that produces better results than the old routines. Improvements always make those at the top of the heap look inept.
38
Name:
Anonymous
2009-08-10 10:58
memes
intelligent
39
Name:
=+=*=F=R=O=Z=E=N==V=O=I=D=*=+=
2009-08-10 10:59
>>37
also, i am a proud member of the hacker group anonymous.
i study their memes so i can be a better hacker like them
__________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum:
http://etastrum.phpbb3now.com
My father fucked me, and i liked it.
40
Name:
Anonymous
2009-08-10 10:59
Honestly, I wouldn't think anyone older than 10 would ever have a disagreement about whether 1 or 2 are prime numbers, but there you go.
41
Name:
Anonymous
2009-08-10 11:09
>>39
Hmmmm.
This post has proper grammar/spelling and doesn't reek of stupidity & arrogance. I call bullshit, this can't possibly be the real FV.
42
Name:
Anonymous
2009-08-10 11:14
So Mr. Void is the mastermind behind all of these /b/'s raids. My, my.
43
Name:
Anonymous
2009-08-10 11:16
44
Name:
Anonymous
2009-08-10 11:19
LULZ
I HERS U LIEK MUDKIPZ
ANON IS LEGION SMART MEMES
EPIC LULZ,
>>43 IS A EPIC FAILFAG FUKKEN LEGENDARY THREAD ARCHIVE NAO TRIFORCE
45
Name:
Anonymous
2009-08-10 11:20
>>44
Nice raid.
/prog/ will be in shambles for days.
46
Name:
Anonymous
2009-08-10 11:21
>>43
Well, when I was at /b/, there were raids, most often as a part of bigger actions (like with Hal Turner or the emo forums (which were ultimately taken over by /b/)). Don't you do that any more?
47
Name:
Anonymous
2009-08-10 11:21
>>45
ANON IS LEGION BUY A DOG AND CURTAINS
48
Name:
Anonymous
2009-08-10 11:23
>>46
oh, like the epik lulz war on scientology?
you're right, FV would totally be into that stuff.
49
Name:
Anonymous
2009-08-10 11:24
>>48
I'm not really into the scientology raids, I happened to leave just as it was starting. But yeah, kinda like that, except with no media coverage.
50
Name:
Anonymous
2009-08-10 11:28
>>38
memes
You keep using that word. I do not think it means what you think it means.
51
Name:
Anonymous
2009-08-10 11:29
52
Name:
Anonymous
2009-08-10 11:36
53
Name:
Jim Black
!eZeTERnAls
2009-08-10 13:17
OP, ignore the trolls and use this. Don't forget to change the variable names or your prof will be able to Google for where you got it.
#include <iostream>
int main() {
char*a="%&(*.046:@BHLNRX^`fjlrv|(,.248FJPR\\^djntz|*,02>"
"JNPTZ\\flrxz$(*4BFHLZ`jlpv~(.28@DLVXbdjnt|$&*6>BJNT`bt";
char*b="########################$$$$$$$$$$$$$$$$$$%%%%%%"
"%%%%%%%%%%&&&&&&&&&&&&&&&'''''''''''''''((((((((((((";
for(char*p=a,*q=b;*p;)std::cout<<*(p++)+*(q++)*92-3255<<
std::endl;}