numbers (version 0.7-5)

ordpn: Order in Faculty

Description

Calculates the order of a prime number p in n!, i.e. the highest exponent e such that p^e|n!.

Usage

ordpn(p, n)

Arguments

p

prime number.

n

natural number.

Value

Returns the exponent e.

Details

Applies the well-known formula adding terms floor(n/p^k).

Examples

Run this code
# NOT RUN {
  ordpn(2, 100)         #=> 97
  ordpn(7, 100)         #=> 16
  ordpn(101, 100)       #=>  0
  ordpn(997, 1000)      #=>  1
# }

Run the code above in your browser using DataCamp Workspace