Emirp primes: Difference between revisions

no edit summary
(Initial FutureBasic task solution added)
No edit summary
Line 422:
948349
</pre>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> REM Taking advantage of inbuilt assembler to implement ultra fast Prime tester!
DIM P% 127:[OPT 0
.F% pop eax:mov eax,0:.T% ret:.M% mov eax,ecx:xor edx,edx:div ebx:cmp edx,0:jz F%:ret
.E% mov ebx,2:call M%:mov ebx,3:call M%:mov ebx,5:.W% mov edx,ebx:imul edx,ebx
cmp edx,ecx:jg T%:call M%:add ebx,2:call M%:add ebx,4:jmp W%:]
DEF FNIsPrime(C%)=USRE%
 
N%=0
P%=11
PRINT "First 20 emirps are:";
WHILE N%<10000
P%+=2
IF FNIsPrime(P%) THEN
R%=VALFNRev(STR$P%)
IF P%<>R% IF FNIsPrime(R%) THEN
IF N%<20 OR (P%>7699 AND P%<8001) PRINT " ";P%;
N%+=1
IF N%=20 PRINT '"Emirps between 7700 and 8000 are:";
ENDIF
ENDIF
ENDWHILE
PRINT '"The 10,000th emirp is: ";P%
END
 
DEF FNRev(n$)
Q%=!^n$
L%=LENn$-1
FOR I%=0 TO L%/2 SWAP Q%?I%, Q%?(L%-I%) NEXT
=n$</syntaxhighlight>
{{out}}
<pre>First 20 emirps are: 13 17 31 37 71 73 79 97 107 113 149 157 167 179 199 311 337 347 359 389
Emirps between 7700 and 8000 are: 7717 7757 7817 7841 7867 7879 7901 7927 7949 7951 7963
The 10,000th emirp is: 948349</pre>
 
=={{header|C}}==
70

edits