Learn R Programming

cwhmisc (version 4.0)

numeric: Number theoretic functions

Description

Simple number theoretic functions

Usage

scm( m, n )
EulerPhi( n )
gcd( m, n )
EuclidExtended( m, n )
modexp( a, b, n )

Arguments

a,b,m,n
Integer

Details

EulerPhi Eulers totient function = #divisors of n. scm, gcd Smallest common multiple, Greatest common divisor. EuclidExtended Computes a, b which solve the equation a*m + b*n = gcd(m,n). modexp Exponentiation modulo an integer.

Examples

Run this code
scm(35,133) # 665
 gcd(35,133) # 7
 EuclidExtended(35,133) #   4 -1, meaning 4*35 -1*133 = 7
 EulerPhi(60) # 16
 modexp(3,10,7)  # 4

Run the code above in your browser using DataLab