Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Ascending-primes/Sidef/ascending-primes.sidef
Normal file
29
Task/Ascending-primes/Sidef/ascending-primes.sidef
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
func primes_with_ascending_digits(base = 10) {
|
||||
|
||||
var list = []
|
||||
var digits = @(1..^base -> flip)
|
||||
|
||||
var end_digits = digits.grep { .is_coprime(base) }
|
||||
list << digits.grep { .is_prime && !.is_coprime(base) }...
|
||||
|
||||
for k in (0 .. digits.end) {
|
||||
digits.combinations(k, {|*a|
|
||||
var v = a.digits2num(base)
|
||||
end_digits.each {|d|
|
||||
var n = (v*base + d)
|
||||
next if ((n >= base) && (a[0] >= d))
|
||||
list << n if (n.is_prime)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
list.sort
|
||||
}
|
||||
|
||||
var arr = primes_with_ascending_digits()
|
||||
|
||||
say "There are #{arr.len} ascending primes.\n"
|
||||
|
||||
arr.each_slice(10, {|*a|
|
||||
say a.map { '%8s' % _ }.join(' ')
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue