Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
23
Task/AKS-test-for-primes/Sidef/aks-test-for-primes.sidef
Normal file
23
Task/AKS-test-for-primes/Sidef/aks-test-for-primes.sidef
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
func binprime(p) {
|
||||
p >= 2 || return false
|
||||
for i in (1 .. p>>1) {
|
||||
(binomial(p, i) % p) && return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func coef(n, e) {
|
||||
(e == 0) && return "#{n}"
|
||||
(n == 1) && (n = "")
|
||||
(e == 1) ? "#{n}x" : "#{n}x^#{e}"
|
||||
}
|
||||
|
||||
func binpoly(p) {
|
||||
join(" ", coef(1, p), ^p -> map {|i|
|
||||
join(" ", %w(+ -)[(p-i)&1], coef(binomial(p, i), i))
|
||||
}.reverse...)
|
||||
}
|
||||
|
||||
say "expansions of (x-1)^p:"
|
||||
for i in ^10 { say binpoly(i) }
|
||||
say "Primes to 80: [#{2..80 -> grep { binprime(_) }.join(' ')}]"
|
||||
Loading…
Add table
Add a link
Reference in a new issue