How many non-negative integers are there with non-repeating digits?
To avoid ambiguity:
Smallest number: 0
Biggest: 9876543210
There are 10 single-digit numbers.
For larger numbers of digits, there's only 9 choices for the first one, as zero's excluded there. There are still 9 choices for the second digits, as zero has now appeared, but the one chosen for first is no longer available. Each subsequent digit has one fewer choices:
10
9*9=81
9*9*8=648
9*9*8*7=4536
9*9*8*7*6=27216
9*9*8*7*6*5=136080
9*9*8*7*6*5*4=544320
9*9*8*7*6*5*4*3=1632960
9*9*8*7*6*5*4*3*2=3265920
9*9*8*7*6*5*4*3*2*1=3265920
tot =
8877691
including the initial 10 1-digit numbers.
The last two terms are the same, as one determines the digit that's not present and the other determines the digit that's last.
To print the above table:
tot=10;
s='9*9';
for i=8:-1:0
disp([s '=' num2str(eval(s))])
tot=tot+eval(s);
s=[s '*' num2str(i)];
end
tot
|
Posted by Charlie
on 2024-04-11 08:45:46 |