ordpn: Order in Faculty

View source: R/ordpn.R

ordpnR Documentation

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.

Details

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

Value

Returns the exponent e.

Examples

  ordpn(2, 100)         #=> 97
  ordpn(7, 100)         #=> 16
  ordpn(101, 100)       #=>  0
  ordpn(997, 1000)      #=>  1

numbers documentation built on Nov. 23, 2022, 9:06 a.m.