Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -1,16 +1 @@
|
|||
extend=: {{ y;(1+each i._1+{.y),L:0 y }}
|
||||
$(#~ 1 p: ])10#.&>([:~.@;extend each)^:# >:i.9
|
||||
100
|
||||
10 10$(#~ 1 p: ])10#.&>([:~.@;extend each)^:# >:i.9
|
||||
2 3 13 23 5 7 17 37 47 67
|
||||
127 137 347 157 257 457 167 367 467 1237
|
||||
2347 2357 3457 1367 2467 3467 1567 4567 12347 12457
|
||||
13457 13567 23567 123457 124567 19 29 59 79 89
|
||||
139 239 149 349 359 269 569 179 379 479
|
||||
389 1249 1259 1459 2459 3469 1279 1579 2579 4679
|
||||
1289 2389 1489 2689 5689 1789 2789 4789 23459 13469
|
||||
12569 12379 12479 13679 34679 15679 25679 12589 34589 12689
|
||||
23689 13789 23789 123479 124679 235679 145679 345679 234589 345689
|
||||
134789 125789 235789 245789 1245689 1234789 1235789 1456789 12356789 23456789
|
||||
timex'(#~ 1 p: ])10#.&>([:~.@;extend each)^:# >:i.9'
|
||||
0.003818
|
||||
_10 ]\ /:~ (#~ 1&p:) 10&#.@I. #: i. 513
|
||||
|
|
|
|||
31
Task/Ascending-primes/Prolog/ascending-primes.pro
Normal file
31
Task/Ascending-primes/Prolog/ascending-primes.pro
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
isPrime(2).
|
||||
isPrime(N):-
|
||||
between(3, inf, N),
|
||||
N /\ 1 > 0, % odd
|
||||
M is floor(sqrt(N)) - 1, % reverse 2*I+1
|
||||
Max is M div 2,
|
||||
forall(between(1, Max, I), N mod (2*I+1) > 0).
|
||||
|
||||
combi(0, _, Num, Num).
|
||||
combi(N, [X|T], Acc, Num):-
|
||||
N > 0,
|
||||
N1 is N - 1,
|
||||
Acc1 is Acc * 10 + X,
|
||||
combi(N1, T, Acc1, Num).
|
||||
combi(N, [_|T], Acc, Num):-
|
||||
N > 0,
|
||||
combi(N, T, Acc, Num).
|
||||
|
||||
ascPrimes(Num):-
|
||||
between(1, 9, N),
|
||||
combi(N, [1, 2, 3, 4, 5, 6, 7, 8, 9], 0, Num),
|
||||
isPrime(Num).
|
||||
|
||||
showList(List):-
|
||||
findnsols(10, DPrim, (member(DPrim, List), writef('%9r', [DPrim])), _),
|
||||
nl,
|
||||
fail.
|
||||
showList(_).
|
||||
|
||||
do:-findall(DPrim, ascPrimes(DPrim), DList),
|
||||
showList(DList).
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import "./math" for Int
|
||||
import "./seq" for Lst
|
||||
import "./fmt" for Fmt
|
||||
|
||||
var isAscending = Fn.new { |n|
|
||||
|
|
@ -23,4 +22,4 @@ var ascPrimes = []
|
|||
for (p in primes) if (isAscending.call(p)) ascPrimes.add(p)
|
||||
ascPrimes.addAll(higherPrimes)
|
||||
System.print("There are %(ascPrimes.count) ascending primes, namely:")
|
||||
for (chunk in Lst.chunks(ascPrimes, 10)) Fmt.print("$8d", chunk)
|
||||
Fmt.tprint("$8d", ascPrimes, 10)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import "./set" for Set
|
||||
import "./math" for Int
|
||||
import "./seq" for Lst
|
||||
import "./fmt" for Fmt
|
||||
|
||||
var ascPrimes = Set.new() // avoids duplicates
|
||||
|
|
@ -23,4 +22,4 @@ for (digits in 1..9) generate.call(1, 0, digits)
|
|||
ascPrimes = ascPrimes.toList
|
||||
ascPrimes.sort()
|
||||
System.print("There are %(ascPrimes.count) ascending primes, namely:")
|
||||
for (chunk in Lst.chunks(ascPrimes, 10)) Fmt.print("$8s", chunk)
|
||||
Fmt.tprint("$8d", ascPrimes, 10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue