Manindra Agrawal & Neeraj Kayal & Nitin Saxena present an unconditional deterministic polynomial-time algorithm that determines whether an input number is prime or composite.
The AKS algorithm for testing whether a number is prime is a polynomial-time algorithm based on an elementary theorem about Pascal triangles.
Rust
1
1 | use std::iter::repeat; |
2
An alternative version which computes the coefficients in a more functional but less efficient way.
1 | fn aks_coefficients(k: usize) -> Vec<i64> { |
Java
1 | public class AksTest { |
JavaScript
Translation of: C
1 | function coef(n) { |
Translation of: CoffeeScript
1 | var i, p, pascal, primerow, primes, show, _i; |
Reviewed (ES6)
1 | function pascal(n) { |