Documentation ¶
Index ¶
- func Add(n1, n2 []int, base int) ([]int, error)
- func BaseToDec(n []int, base int) (int, error)
- func DecToBase(n, base int) ([]int, error)
- func GreatestCommonDivisor(a, b int) int
- func IsValidNumber(n []int, base int) bool
- func NewErrInvalidBase() error
- func PrimeFactorization(inputNumber int) (map[int]int, error)
- func Subtract(n1, n2 []int, base int) ([]int, error)
- type ErrInvalidBase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GreatestCommonDivisor ¶
GreatestCommonDivisor is a function that calculates the greatest common divisor (GCD) of two integers using the Euclidean algorithm.
Parameters:
- a, b: The two integers to find the GCD of.
Returns:
- int: The GCD of the two input numbers.
func IsValidNumber ¶ added in v0.2.18
func NewErrInvalidBase ¶ added in v0.2.18
func NewErrInvalidBase() error
func PrimeFactorization ¶
PrimeFactorization is a function that performs prime factorization on an input number.
Panics with an error of type *ErrInvalidParameter if the input number is 0.
In the resulting map, no prime factor will have a value of 1, except for 1 and -1, which is represented as [1: 1]. Finally, negative numbers are converted to positive numbers.
Parameters:
- inputNumber: The number to factorize.
Returns:
- map[int]int: A map where the keys are the prime factors and the values are their respective powers.
Types ¶
type ErrInvalidBase ¶ added in v0.2.18
type ErrInvalidBase struct{}
func (*ErrInvalidBase) Error ¶ added in v0.2.18
func (e *ErrInvalidBase) Error() string
Click to show internal directories.
Click to hide internal directories.