numer: Number theoretic functions

Description Usage Arguments Value Author(s) References Examples

Description

Simple number theoretic functions

Usage

1
2
3
4
5
6
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

1
2
3
4
5
 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

Example output

Loading required package: lattice
Loading required package: grid
[1] 665
[1] 7
[1] -1  4  7
[1] 16
[1] 4

cwhmisc documentation built on May 1, 2019, 7:55 p.m.