Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

numer

Number theoretic functions


Description

Simple number theoretic functions

Usage

scm( m, n )
EulerPhi( n )
gcd( a, b )
Euclid( a, b )
Inv(a, n)
modexp( a, b, n )

Arguments

a,b,m,n

Integer

Value

EulerPhi Eulers totient function = number of divisors of n. scm, gcd Smallest common multiple, Greatest common divisor. Euclid Computes x, y from a, b such that the equation a*x + b*y = gcd(m,n) is satisfied. Inv Modular inverse in a finite ring, NA if not exists. modexp Exponentiation a^b mod n using repeated squaring via binary decomposition of exponent.

Author(s)

Christian W. Hoffmann <christian@echoffmann.ch>

References

modexp: http://mvngu.wordpress.com/2008/08/01/parigp-programming-for-basic-cryptography/

Examples

scm(35,133) # 665
 gcd(35,133) # 7
 Euclid(35,133) #  -1 4 7, meaning 4*35 +(-1)*133 = 7
 EulerPhi(60) # 16
 modexp(3,10,7)  # 3^10 mod 7: 4

cwhmisc

Miscellaneous Functions for Math, Plotting, Printing, Statistics, Strings, and Tools

v6.6
GPL (>= 2)
Authors
Christian W. Hoffmann
Initial release
2018-08-24, 10:40:10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.