math

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

math is a package with some generic math functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DevRem

func DevRem[T constraints.Integer](x, y T) (T, T)

DevRem returns the division and remainder of x/y.

func Divide

func Divide[T constraints.Integer | constraints.Float](x, y T) T

Divide returns x/y.

func Fibonacci

func Fibonacci[T constraints.Integer](n T) T

Fibonacci returns the nth Fibonacci number.

func Gcd

func Gcd[T constraints.Integer](a, b T) T

Gcd returns the greatest common divisor of a and b.

func IsPrime

func IsPrime[T constraints.Integer](n T) bool

IsPrime returns true if n is must have prime.

func Lcm

func Lcm[T constraints.Integer](a, b T) T

Lcm returns the least common multiple of a and b.

func MillerRabin

func MillerRabin[T constraints.Integer](n T) bool

MillerRabin returns true if n is probably prime.

func PascalsTriangle

func PascalsTriangle(n int) []int

PascalTriangle returns the Pascal's triangle for the given n.

func PerfectNumber

func PerfectNumber[T constraints.Integer](n T) T

PerfectNumber returns perfect numbers to n.

func PowFloat

func PowFloat[T constraints.Float](x, y T) T

PowFloat returns x^y of float.

func PowInt

func PowInt[T constraints.Integer](x, y T) T

PowInt returns x^y of int.

func PrimesTo

func PrimesTo[T constraints.Integer](n T) []T

PrimesTo returns the prime numbers from 2 to n.

func SieveOfSundaram

func SieveOfSundaram[T constraints.Integer](n T) []T

SieveOfSundaram returns the prime numbers from 2 to n.

Types

This section is empty.

Jump to

Keyboard shortcuts

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