MathExt

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GreatestCommonDivisor

func GreatestCommonDivisor(a, b int) int

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 PrimeFactorization

func PrimeFactorization(inputNumber int) map[int]int

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

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL