The probability of $n$ being a square, given the units-digit in its decimal representation

97 Views Asked by At

Given a natural number $n\in[1,N]$, the probability of $n$ being a perfect square is $\frac{1}{\sqrt{N}}$.

What would be the probability, if we knew the units-digit in the decimal representation of $n$?

I have figured out the following:

  • $d=0 \implies p=K$
  • $d=1 \implies p=2K$
  • $d=2 \implies p=0$
  • $d=3 \implies p=0$
  • $d=4 \implies p=2K$
  • $d=5 \implies p=K$
  • $d=6 \implies p=2K$
  • $d=7 \implies p=0$
  • $d=8 \implies p=0$
  • $d=9 \implies p=2K$

I assume that $K$ should be derived from $\frac{1}{\sqrt{N}}$, but I'm not quite sure how.

I was thinking, perhaps the above probabilities should sum up to $\frac{1}{\sqrt{N}}$.

This would yield $K=\frac{1}{10\sqrt{N}}$.

Is that correct, or do I need to take a different approach here?

2

There are 2 best solutions below

1
On BEST ANSWER

The probabilities should not sum up to $\frac1{\sqrt N}$. Contemplate the problem with "square" replaced with "even", where you should have $p=1$ or $p=0$, depending on the unit digit being even/odd, whereas the overall probaility is $\frac12$.

Instead, your $K$ should be just $\frac1{\sqrt N}$, do you see why?

0
On

I'm not sure about my answer and be glad that someone point out eventual mistakes. I thought in term of probabilities, it seems a little bit complicated, there may be a more simple solution.

Let say
$A = \text{the event that n is a perfect square}$
$Bi = \text{the event that i is the unit-digit}$

First, $P(Bi) \ne \frac{1}{10}$ cause it depend on the unit digit of N. It's only true if N finish by 0.
$P(Bi) = f(i,N) = \frac{10*[\frac{N}{10}]}{N}$ if $i \le N-10*[\frac{N}{10}]$
$P(Bi) = f(i,N) = \frac{10*[\frac{N}{10}]-1}{N}$ if $i \gt N-10*[\frac{N}{10}]$

Then,
$P(A|Bi)=\frac{P(A)}{P(Bi)}*P(Bi|A)$

So let's focus on $P(Bi|A)$
If n is a perfect square, $\sqrt{n}\in [1;[\sqrt{N}]]$. Let's say $M=[\sqrt{N}]$
So $P(Bi|A)=$the probability that $i$ can be the unit-digit of the square of the unit-digit of$\sqrt{n}$ so the the porbability to have these unit-digits in $[1;M]$
So its (with f defined ealier):
$i=0 \implies P(Bi|A)=f(0,M)$
$i=1 \implies P(Bi|A)=f(1,M)+f(9,M)$
$i=2 \implies P(Bi|A)=0$
$i=3 \implies P(Bi|A)=0$
$i=4 \implies P(Bi|A)=f(2,M)+f(8,M)$
$i=5 \implies P(Bi|A)=f(5,M)$
$i=6 \implies P(Bi|A)=f(4,M)+f(6,M)$
$i=7 \implies P(Bi|A)=0$
$i=8 \implies P(Bi|A)=0$
$i=9 \implies P(Bi|A)=f(3,M)+f(7,M)$

Finally you get this list and you multiply by $\frac{P(A)}{P(Bi)}$ to get your answer.