0

In the wiki article for Legendre's formula see here, it is said the formula is for prime number, but after reading this simply amazing explanation of the formula in this mse post, I think that it can be used for knowing how many times a composite number goes into another number. For example, consider the number of times $4$ goes into 5!, it is given as:

$$ \lfloor \frac{5}{4} \rfloor$$

Which is one, and is exactly the number of times $4$ is a factor of the above. Does this always work or am I missing something?

  • 1
    For a counterexample, change your 5 to a 6. – Karl Feb 09 '21 at 23:00
  • Hmm it failed.. but I don't get why @Karl – Clemens Bartholdy Feb 09 '21 at 23:02
  • 2
    The 2 and the 6 in $6!$ together contribute an extra factor of 4 that Legendre's formula "doesn't see" because they aren't multiples of 4. – Karl Feb 09 '21 at 23:06
  • But $\left\lfloor\frac {5}{4}\right\rfloor$ is not $2$ - it's $1$. Which, to your point, is indeed the power of $4$ that divides evenly into $5!$, although "one and a half" would be closer as there is still a factor of $2$ left in $120/4^1=30$. – Joffan Feb 09 '21 at 23:08
  • Yeah, I think I get the issue now – Clemens Bartholdy Feb 09 '21 at 23:12
  • 3
    Btw, you can get the desired result for a composite number by applying Legendre's formula separately to each of its prime factors and taking a minimum: $\max{k:m^k|n}=\min_{p|m}\lfloor \nu_p(n)/\nu_p(m)\rfloor$. – Karl Feb 09 '21 at 23:22
  • @Karl what's the idea behind the formula you have written? – Clemens Bartholdy Feb 09 '21 at 23:27
  • 1
    The idea is that $m^k|n$ iff every prime power in the prime factorization of $m^k$ divides $n$. So we look at how many of each prime we can "fit into" $n$. Each prime gives us a different "largest possible $k$", so the smallest of those bounds is our actual answer. – Karl Feb 09 '21 at 23:29
  • 1
    If you play around with some examples and pay attention to the prime factorizations, you'll see what's going on. – Karl Feb 09 '21 at 23:32

0 Answers0