Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

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

Number-Theoretic Functions

v0.8-1
GPL (>= 3)
Authors
Hans Werner Borchers
Initial release
2021-04-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.