-
Notifications
You must be signed in to change notification settings - Fork 0
/
sieve_of_eratosthenes.lol
66 lines (52 loc) · 2.04 KB
/
sieve_of_eratosthenes.lol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
HAI 1.3
OBTW
This is a LOLCODE implementation of the Sieve of Eratosthenes to find prime
numbers.
Further information about the sieve can be found here:
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
This code is using BUKKITS as proposed in LOLCODE 1.3 and implemented in
the LOLCODE interpreter LCI by Justin Meza (future branch):
http://www.icanhaslolcode.org
TLDR
BTW O HAI, IM IN UR NUMBRS SIEVING UR PRIMEZ LIEK ERATOSTHENES
HOW IZ I SIEVING4PRIMEZ YR MAXIMUM
I HAS A BUKKITOFNUMBRS ITZ A BUKKIT
I HAS A GOAWAEY ITZ 0
I HAS A POINTR ITZ 0
BTW INITUALIZING UR BUKKIT
IM IN YR NUMBRS UPPIN YR COUNTR WILE BOTH SAEM COUNTR AN SMALLR OF COUNTR AN DIFF OF MAXIMUM AN 1
POINTR R SUM OF COUNTR AN 1
BUKKITOFNUMBRS HAS A SRS POINTR ITZ WIN
IM OUTTA YR NUMBRS
BUKKITOFNUMBRS'Z SRS 1 R FAIL
BTW LOOKIN FO PRIMEZ
IM IN YR NUMBRS UPPIN YR COUNTR WILE BOTH SAEM COUNTR AN SMALLR OF COUNTR AN DIFF OF MAXIMUM AN 1
POINTR R SUM OF COUNTR AN 1
BTW IS DIS NUMBR MEBBE PRIME?
BUKKITOFNUMBRS'Z SRS POINTR, O RLY?
YA RLY
BTW ALL MULTIPLES OF DIS NUMBR CAN NOT IS PRIME
IM IN YR NUMBRSAGAIN UPPIN YR MULTIPLIR WILE BOTH SAEM GOAWAEY AN SMALLR OF GOAWAEY AN DIFF OF MAXIMUM AN 1
GOAWAEY R SUM OF POINTR AN PRODUKT OF SUM OF MULTIPLIR AN 1 AN POINTR
BOTH SAEM GOAWAEY AN SMALLR OF GOAWAEY AN MAXIMUM, O RLY?
YA RLY
BUKKITOFNUMBRS'Z SRS GOAWAEY R FAIL
OIC
IM OUTTA YR NUMBRSAGAIN
GOAWAEY R 0
OIC
IM OUTTA YR NUMBRS
FOUND YR BUKKITOFNUMBRS
IF U SAY SO
BTW IMA SHOW U TEH PRIMEZ
I HAS A POINTR ITZ 0
I HAS A MAXIMUM ITZ 100
I HAS A BUKKITOFPRIMEZ ITZ I IZ SIEVING4PRIMEZ YR MAXIMUM MKAY
IM IN YR PRIMEZ UPPIN YR COUNTR WILE BOTH SAEM COUNTR SMALLR OF COUNTR AN DIFF OF MAXIMUM AN 1
POINTR R SUM OF COUNTR AN 1
BUKKITOFPRIMEZ'Z SRS POINTR, O RLY?
YA RLY
VISIBLE SMOOSH POINTR AN " IZ PRIME!" MKAY
OIC
IM OUTTA YR PRIMEZ
KTHXBYE