number

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseExp

func BaseExp(N int, eps ...float64) (int, int, bool)
Example
Output:

5^3 true

func ContinuedFraction

func ContinuedFraction(real float64, eps ...float64) []int
Example
Output:

[0 1 4 3] 13/16=0.8125

func Convergent

func Convergent(cfx []int) (int, int, float64)
Example
Output:

0.00101010101=0.16650390625 <nil>
[0]: 0/1=0
[0 6]: 1/6=0.16666666666666666
[0 6 170]: 170/1021=0.1665034280117532
[0 6 170 1]: 171/1027=0.1665043816942551
[0 6 170 1 1]: 341/2048=0.16650390625

func FindOrder

func FindOrder(a, N int, binary string, eps ...float64) (int, int, float64, bool)

FindOrder returns convergent s/r and its real number such that a**r mod N = 1.

Example (Mod15)
Output:

3/4=0.75 true
7^4 mod 15 = 1
Example (Mod21a2)
Output:

1/6=0.16666666666666666 true
2^6 mod 21 = 1
Example (Mod21a4)
Output:

1/3=0.3333333333333333 true
4^3 mod 21 = 1

func GCD

func GCD(a, b int) int
Example
Output:

1

func IsEven

func IsEven(v int) bool

func IsOdd

func IsOdd(v int) bool

func IsPrime

func IsPrime(N int) bool

func IsTrivial

func IsTrivial(N int, factor ...int) bool
Example
Output:

true
false

func Max

func Max(p []float64) float64

func Min

func Min(p []float64) float64

func ModExp

func ModExp(a, r, N int) int

ModExp returns a**r mod N.

Example
Output:

1

func ModExp2

func ModExp2(a, j, N int) int

ModExp2 returns a**(2**j) mod N.

Example
Output:

1

func Must

func Must[T any](v T, err error) T

func ParseFloat

func ParseFloat(binary string) (float64, error)
Example
Output:

0.625 <nil>

func Pow

func Pow(a, r int) int

Pow returns a**r, the base-a exponential of r.

func Sum

func Sum(p []float64) float64

Types

This section is empty.

Jump to

Keyboard shortcuts

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