Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
29
Task/Emirp-primes/BBC-BASIC/emirp-primes.basic
Normal file
29
Task/Emirp-primes/BBC-BASIC/emirp-primes.basic
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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$
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import "/math" for Int
|
||||
import "./math" for Int
|
||||
|
||||
var isEmirp = Fn.new{ |n|
|
||||
if (!Int.isPrime(n)) return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue