AKS test for primes: Difference between revisions

(Added Quackery.)
 
(4 intermediate revisions by 3 users not shown)
Line 1,206:
 
=={{header|Clojure}}==
{{incorrect|Clojure|(x-1)(x-1) is x^2-2x+1 so should the result 2 (-1 2 1) rather be 2 (1 2 1) and similarly for several others}}
The *' function is an arbitrary precision multiplication.
<syntaxhighlight lang="clojure">(defn c
Line 1,480 ⟶ 1,481:
=={{header|Elena}}==
{{trans|C#}}
ELENA 46.x :
<syntaxhighlight lang="elena">import extensions;
Line 1,495 ⟶ 1,496:
c[i] := 1l;
for (int i := 0,; i < n,; i += 1) {
c[1 + i] := 1l;
for (int j := i,; j > 0,; j -= 1) {
c[j] := c[j - 1] - c[j]
};
Line 1,535 ⟶ 1,536:
public program()
{
for (int n := 0,; n < 10,; n += 1) {
AksTest.coef(n);
Line 1,544 ⟶ 1,545:
console.print("Primes:");
for (int n := 1,; n <= 63,; n += 1) {
if (AksTest.is_prime(n))
{
Line 1,680 ⟶ 1,681:
 
The primes upto 50: [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
</pre>
 
=={{header|F_Sharp|F#}}==
<syntaxhighlight lang="fsharp">
// N-grams. Nigel Galloway: April 11th., 2024
let fN g=let n,g=g@[0I],0I::g in List.map2(fun n g->n-g) n g
Seq.unfold(fun g->Some(g,fN g))[1I]|>Seq.take 9|>Seq.iteri(fun n g->printfn "%d -> %A" n g); printfn ""
let fG (n::g) l=(n+1I)%l=0I && g|>List.forall(fun n->n%l=0I)
Seq.unfold(fun(n,g)->Some((n,g),(n+1I,fN g)))(0I,[1I])|>Seq.skip 2|>Seq.filter(fun(n,_::g)->fG (List.rev g) n)|>Seq.takeWhile(fun(n,_)->n<100I)|>Seq.iter(fun(n,_)->printf "%A " n); printfn ""
</syntaxhighlight>
{{out}}
<pre>
0 -> [1]
1 -> [1; -1]
2 -> [1; -2; 1]
3 -> [1; -3; 3; -1]
4 -> [1; -4; 6; -4; 1]
5 -> [1; -5; 10; -10; 5; -1]
6 -> [1; -6; 15; -20; 15; -6; 1]
7 -> [1; -7; 21; -35; 35; -21; 7; -1]
8 -> [1; -8; 28; -56; 70; -56; 28; -8; 1]
 
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
</pre>
 
Line 5,921 ⟶ 5,945:
=={{header|Wren}}==
{{trans|Go}}
<syntaxhighlight lang="ecmascriptwren">var bc = Fn.new { |p|
var c = List.filled(p+1, 0)
var r = 1
2,172

edits