Skip to content

Number theory ​

FunctionSignatureDescription
isPrime(n: u64) => booleantrue if n is prime
nextPrime(n: u64) => u64Smallest prime strictly greater than n
primeFactors(n: u64) => u64[]Prime factors of n
fibonacci(n: u64) => u64n-th Fibonacci number

isPrime() ​

Returns true if n is prime.

SignatureisPrime(n: u64): boolean
tyrus
const n: u64 = 17;
const result: boolean = isPrime(n);
print(result); // true

nextPrime() ​

Returns the smallest prime strictly greater than n.

SignaturenextPrime(n: u64): u64
tyrus
const n: u64 = 17;
const result: u64 = nextPrime(n);
print(result); // 19

primeFactors() ​

Returns the prime factors of n.

SignatureprimeFactors(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.

Signaturefibonacci(n: u64): u64
tyrus
const n: u64 = 10;
const result: u64 = fibonacci(n);
print(result); // 55