Learn R Programming

cwhmisc (version 6.0)

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 modulo an integer via binary decomposition of exponent.

Examples

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

Run the code above in your browser using DataLab