Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Truncatable-primes/Zkl/truncatable-primes-1.zkl
Normal file
15
Task/Truncatable-primes/Zkl/truncatable-primes-1.zkl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const million=0d1_000_000;
|
||||
|
||||
var pTable=Data(million+1,Int).fill(0); // actually bytes, all zero
|
||||
primes:=Utils.Generator(Import("sieve").postponed_sieve);
|
||||
while((p:=primes.next())<million){ pTable[p]=1; }
|
||||
|
||||
fcn rightTrunc(n){
|
||||
while(n){ if(not pTable[n]) return(False); n/=10; }
|
||||
True
|
||||
}
|
||||
fcn leftTrunc(n){ // 999,907 is not allowed
|
||||
ns:=n.toString(); if (ns.holds("0")) return(False);
|
||||
while(ns){ if(not pTable[ns]) return(False); ns=ns[1,*]; }
|
||||
True
|
||||
}
|
||||
4
Task/Truncatable-primes/Zkl/truncatable-primes-2.zkl
Normal file
4
Task/Truncatable-primes/Zkl/truncatable-primes-2.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[million..0,-1].filter1(rightTrunc):
|
||||
"%,d is a right truncatable prime".fmt(_).println();
|
||||
[million..0,-1].filter1(leftTrunc):
|
||||
"%,d is a left truncatable prime".fmt(_).println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue