Number theory
| Function | Signature | Description |
|---|---|---|
isPrime | (n: u64) => boolean | true if n is prime |
nextPrime | (n: u64) => u64 | Smallest prime strictly greater than n |
primeFactors | (n: u64) => u64[] | Prime factors of n |
fibonacci | (n: u64) => u64 | n-th Fibonacci number |
isPrime()
Returns true if n is prime.
Signature
isPrime(n: u64): booleantyrus
const n: u64 = 17;
const result: boolean = isPrime(n);
print(result); // truenextPrime()
Returns the smallest prime strictly greater than n.
Signature
nextPrime(n: u64): u64tyrus
const n: u64 = 17;
const result: u64 = nextPrime(n);
print(result); // 19primeFactors()
Returns the prime factors of n.
Signature
primeFactors(n: u64): u64[]tyrus
const n: u64 = 60;
const result: u64[] = primeFactors(n);
print(result); // [2, 2, 3, 5]fibonacci()
Returns the n-th Fibonacci number.
Signature
fibonacci(n: u64): u64tyrus
const n: u64 = 10;
const result: u64 = fibonacci(n);
print(result); // 55