KBigMath

object KBigMath

Mathematical utility functions for KBigDecimal and KBigInteger. Provides advanced mathematical operations not available in the basic interfaces.

Functions

Link copied to clipboard

Calculates the factorial of a KBigInteger (n!). The factorial of n is the product of all positive integers less than or equal to n.

Link copied to clipboard

Calculates the greatest common divisor (GCD) of two KBigIntegers using Euclid's algorithm. The GCD is the largest positive integer that divides both numbers without remainder.

Link copied to clipboard

Checks if a KBigInteger is a prime number using trial division. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

Link copied to clipboard

Calculates the least common multiple (LCM) of two KBigIntegers. The LCM is the smallest positive integer that is divisible by both numbers.

Link copied to clipboard
fun pow(base: KBigInteger, exponent: KBigInteger): KBigInteger

Calculates the power of a KBigInteger raised to another KBigInteger exponent using binary exponentiation. This method efficiently computes base^exponent.

Link copied to clipboard
fun sqrt(value: KBigDecimal, scale: Int = 10): KBigDecimal

Calculates the square root of a KBigDecimal using Newton's method for iterative approximation.