Nasm 679 바이트 (Intelion Intel 386 CPU 120 바이트)
isPrime1:
push ebp
mov ebp,dword[esp+ 8]
mov ecx,2
mov eax,ebp
cmp ebp,1
ja .1
.n: xor eax,eax
jmp short .z
.1: xor edx,edx
cmp ecx,eax
jae .3
div ecx
or edx,edx
jz .n
mov ecx,3
mov eax,ebp
.2: xor edx,edx
cmp ecx,eax
jae .3
mov eax,ebp
div ecx
or edx,edx
jz .n
inc ecx
inc ecx
jmp short .2
.3: xor eax,eax
inc eax
.z: pop ebp
ret 4
Np:
push esi
push edi
mov esi,dword[esp+ 12]
xor edi,edi
or esi,esi
ja .0
.e: xor eax,eax
jmp short .z
.0: inc esi
jz .e
push esi
call isPrime1
add edi,eax
dec esi
cmp edi,dword[esp+ 12]
jae .1
add esi,dword[esp+ 12]
jc .e
jmp short .0
.1: mov eax,esi
inc eax
.z: pop edi
pop esi
ret 4
이것은 ungolfed 하나이며 결과
;0k,4ra,8Pp
isPrime1:
push ebp
mov ebp, dword[esp+ 8]
mov ecx, 2
mov eax, ebp
cmp ebp, 1
ja .1
.n: xor eax, eax
jmp short .z
.1: xor edx, edx
cmp ecx, eax
jae .3
div ecx
or edx, edx
jz .n
mov ecx, 3
mov eax, ebp
.2: xor edx, edx
cmp ecx, eax
jae .3
mov eax, ebp
div ecx
or edx, edx
jz .n
inc ecx
inc ecx
jmp short .2
.3: xor eax, eax
inc eax
.z:
pop ebp
ret 4
; {1, n+1, 2n+1, 3n+1 }
; argomento w, return il w-esimo primo nella successione di sopra
;0j,4i,8ra,12P
Np:
push esi
push edi
mov esi, dword[esp+ 12]
xor edi, edi
or esi, esi
ja .0
.e: xor eax, eax
jmp short .z
.0: inc esi
jz .e
push esi
call isPrime1
add edi, eax
dec esi
cmp edi, dword[esp+ 12]
jae .1
add esi, dword[esp+ 12]
jc .e
jmp short .0
.1: mov eax, esi
inc eax
.z:
pop edi
pop esi
ret 4
00000975 55 push ebp
00000976 8B6C2408 mov ebp,[esp+0x8]
0000097A B902000000 mov ecx,0x2
0000097F 89E8 mov eax,ebp
00000981 81FD01000000 cmp ebp,0x1
00000987 7704 ja 0x98d
00000989 31C0 xor eax,eax
0000098B EB28 jmp short 0x9b5
0000098D 31D2 xor edx,edx
0000098F 39C1 cmp ecx,eax
00000991 731F jnc 0x9b2
00000993 F7F1 div ecx
00000995 09D2 or edx,edx
00000997 74F0 jz 0x989
00000999 B903000000 mov ecx,0x3
0000099E 89E8 mov eax,ebp
000009A0 31D2 xor edx,edx
000009A2 39C1 cmp ecx,eax
000009A4 730C jnc 0x9b2
000009A6 89E8 mov eax,ebp
000009A8 F7F1 div ecx
000009AA 09D2 or edx,edx
000009AC 74DB jz 0x989
000009AE 41 inc ecx
000009AF 41 inc ecx
000009B0 EBEE jmp short 0x9a0
000009B2 31C0 xor eax,eax
000009B4 40 inc eax
000009B5 5D pop ebp
000009B6 C20400 ret 0x4
68
000009B9 56 push esi
000009BA 57 push edi
000009BB 8B74240C mov esi,[esp+0xc]
000009BF 31FF xor edi,edi
000009C1 09F6 or esi,esi
000009C3 7704 ja 0x9c9
000009C5 31C0 xor eax,eax
000009C7 EB1D jmp short 0x9e6
000009C9 46 inc esi
000009CA 74F9 jz 0x9c5
000009CC 56 push esi
000009CD E8A3FFFFFF call 0x975
000009D2 01C7 add edi,eax
000009D4 4E dec esi
000009D5 3B7C240C cmp edi,[esp+0xc]
000009D9 7308 jnc 0x9e3
000009DB 0374240C add esi,[esp+0xc]
000009DF 72E4 jc 0x9c5
000009E1 EBE6 jmp short 0x9c9
000009E3 89F0 mov eax,esi
000009E5 40 inc eax
000009E6 5F pop edi
000009E7 5E pop esi
000009E8 C20400 ret 0x4
000009EB 90 nop
120
[0, 0] [1, 2] [2, 5] [3, 19] [4, 29] [5, 71] [6, 43] [7, 211] [8, 193] [9, 271] [1
0, 191] [11, 661] [12, 277] [13, 937] [14, 463] [15, 691] [16, 769] [17, 1531] [18
, 613] [19, 2357] [20, 1021] [21, 1723] [22, 1409] [23, 3313] [24, 1609] [25, 3701
] [26, 2029] [27, 3187] [28, 2437] [29, 6961] [30, 1741] [31, 7193] [32, 3617] [33
, 4951] [34, 3877] [35, 7001] [36, 3169] [37, 10657] [38, 6271] [39, 7879] [40, 55
21] [41, 13613] [42, 3823] [43, 15137] [44, 7349] [45, 9091] [46, 7499] [47, 18049
] [48, 6529] [49, 18229] [50, 7151] [51, 13159] [52, 10141] [53, 26501] [54, 7669]
[55, 19801] [56, 11593] [57, 18127] [58, 13109] [59, 32569] [60, 8221] [61, 34649
] [62, 17981] [63, 21799] [64, 16001] [65, 28081] [66, 10429] [67, 39799] [68, 193
81] [69, 29947] [70, 14771] [71, 47713] [72, 16417] [73, 51539] [74, 25013] [75, 2
9101] [76, 26449] [77, 50051] [78, 16927] [79, 54037] [80, 23761] [81, 41149] [82,
31489] [83, 68891] [84, 19237] [85, 51341] [86, 33713] [87, 45589] [88, 34057] [8
9, 84551] [90, 19531] [91, 64793] [92, 42689] [93, 54499] [94, 41737] [95, 76001]
[96, 27457] [97, 97583] [98, 40867] [99, 66529] [100, 39301] [101, 110899] [102, 2
9989] [103, 116803] [104, 49297] [105, 51871] [106, 56711] [107, 126047] [108, 385
57] [109, 133853] [110, 42901] [111, 76369] [112, 53089] [113, 142607] [114, 40129
] [115, 109481] [116, 63337] [117, 83071] [118, 67733] [119, 112337] [120, 41281]
[121, 152219] [122, 70639] [123, 102337]