Why is this true: ((π-1)!)mod(π) = ((π-1)!)
Messing around with mathematica wolfram alpha and found that out... Why is it?
Update:Eh, it seems it works for -1 and any number greater than 1 and less than somewhere around 3.49
I don't even know anymore...
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Verified answer
This is an interesting, if somewhat random, question. When x and p are positive numbers at least, it appears to interpret "x mod p" in any one of the following equivalent ways:
(1) "x mod p" is the unique number in the interval [0,p) that differs from x by an integer multiple of p. For example, "24 mod pi" is 2.00885ish because this number is in the interval [0, pi) and the difference 24 - 2.00885 = 21.99115ish is 7pi.
(2) "x mod p" is the number you get by marking off the positive multiples of p on the number line, and computing the distance from x to the nearest multiple of p that is less than it. (Speaking somewhat less formally, it's the number x represents if you imagine that the number line starts over at 0, at each multiple of p.) For example, 24 mod pi is 2.00885ish because if you mark off the multiples of pi on the number line, the one closest to 24, and to the left of 24, is 7pi = 21.9115ish and the difference 24 - 21.9115ish is 2.00885ish.
(3) To compute x mod p, first compute the regular quotient x/p, and discard the whole number part, if any. Take what's left and multiply it by p. That's "x mod p". For example, to compute 24 mod pi, compute 24/pi = 7.6394372..., discard the 7, and multiply the .6394372 by pi, giving you 2.00885... this is Wolfram alpha's "24 mod pi."
So, whenever p is a positive number, Wolfram alpha's "x mod p" will be x precisely when x is in the interval [0,p). For example, 1 mod pi will be 1, and 1.35453443 mod pi will be 1, and any number greater than 0, and less than pi, will be equal to itself mod pi.
It turns out that this is why (pi - 1)! mod pi returns (pi - 1)!... because the number (pi - 1)! is in the interval [0,pi). This isn't obvious, though, because the meaning of (pi - 1)! isn't obvious; you need to know enough math to know the convention Wolfram alpha is using here.
To make sense of (pi - 1)! you need to be able to make sense of the expression n! when n is not an integer. This is usually done with a function called the Gamma function. To define this function, you need to know calculus (or at least some rather advanced math), but it turns out that there's this function Gamma(x) defined for all positive x (there's an issue with defining it at 0) and n! = Gamma(n+1) happens to hold for all positive integers n, so people use Gamma(x + 1) as the definition of x! when x > 0 is not a positive integer. To compute "(pi - 1)!" you then evaluate Gamma(pi - 1 + 1) = Gamma(pi). To do this you need to know calculus (or have some other similarly advanced way of understanding the gamma function) but it turns out that Gamma(pi) is about 2.288ish--- ie, it is bigger than 0 and less than pi. So that's why Wolfram alpha says that it is equal to itself mod pi.
The transition you are noticing for positive numbers p, when Wolfram's "(p - 1)! mod p" stops being equal to (p - 1)!, occurs exactly when (p - 1)! = Gamma(p) stops being less than p. To figure out where this is, you need to solve the equation Gamma(p) = p for p. This requires advanced tools to solve but it turns out to happen around 3.56, which is what you were noticing. The significance of this point is that it's where Gamma, the "continuous" version of the factorial function, stops outputting a number that is less than p, and starts outputting a number that is bigger than p (and hence, when it is computed "mod p", will not be itself anymore).
The behavior you are noticing for non-positive input seems to be related to the behavior of the gamma function for non-positive values.