Given that 1 3 ! = 1 3 × 1 2 × 1 1 × ⋅ ⋅ ⋅ × 2 × 1 = 6 2 2 7 0 2 0 8 0 0 , it can be seen that 1 3 ! contains two trailing zeroes.
How many trailing zeroes does 1 0 0 0 ! contain?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This should not have been a level 4 problem. @abdulrahman khaled
Log in to reply
It doesn't deserves level 4 must be a level 3, 2
Now it's level 3 ,, it was a mistake
Here Floor function is quiet similar to Box function. Right sir? I have used Box function to do it.
Log in to reply
I thought the function was z(n)=sigma(i=1)k(2n/10^i)
Log in to reply
It is likely that you will get the same answer. We need only to count the power of 5 which is equal to the power of 10. Because for every 5 there are three to four 2's.
I don't know if there is a box function. I think it is because some use [ ⋅ ] (for convenience) because the floor function symbol ⌊ ⋅ ⌋ is not available to them.
any other method sir @Anuj Shikarkhane @abdulrahman khaled @Parth Lohomi @Chew-Seong Cheong
Log in to reply
I hope that will be clear for you every time a number is multiplied by 10 an extra trailing zero is added, and as 10 = 2 times 5, we need only consider the number of factors of 5 present in 1000!; there are an abundance of factors of 2.
There are 1000/5=200 factors of 5, but we must also ensure that we take into account 25 = 5 times 5, which contains two factors of 5; hence there will be 1000/25=40 extra factors of 5. Similarly, 125 = 5 3 , contains three factors of 5, and 625 = 5 4 .
1000/5 = 200, 1000/25 = 40, 1000/125 = 8, and 1000/625 = 1.6.
Therefore, 1000! contains, 200 + 40 + 8 + 1 = 249 trailing zeroes.
I figured this formula out. It's just the power of 5 in the prime factorisation of n! (every 5 will always find a 2 to buddy up with and make a 10), which come from the 5s within the numbers we multiply together: 1 for every multiple of 5, two for every multiple of 25, three for every multiple of 125, etc.
Log in to reply
Yes, I realised the same thing when solving a similar earlier problem in Brilliant.org. You will discover more.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
A special case of de Polignac's (or Legendre's) Formula for trailing zeroes gives us:
f ( n ) = i = 1 ∑ k ⌊ n / 5 i ⌋ = ⌊ n / 5 ⌋ + ⌊ n / 5 2 ⌋ + ⌊ n / 5 3 ⌋ + ⌊ n / 5 4 ⌋ + . . . + ⌊ n / 5 k ⌋ .
Plugging 1 0 0 0 in for n , we have 2 0 0 + 4 0 + 8 + 1 = 2 4 9 , our final answer.
You round then to floor, right? Yet I don't get the same answer.
Interesting option.
We can simply let i = 1 ∑ ∞ ⌊ 5 i 1 0 0 0 ⌋ , since from some point all addends will be zero :)
Very simple solution:
To form a 0 you need a 2 and a 5 multiplied. It is obvious that there are more 5s than 2s, so the number of 0s is equal to the number of 5s.
Number of 5s = Number of trailing 0s = 200 + 40 + 8 + 1 = 2 4 9
The proof of Legendre-de Polignac's formula (see Keshav solution) is based on this :)
There are more 2s than 5s but yes my process is the same
I believe you have a small mistake with your solution.
On your 4th row; "Numbers that have 4 fives" you list "1000/25", shouldn't you have listed "1000/625" as it is 1000/5^4.
(1000)! = 402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
No. of trailing zeroes = 249
The number of zeros can be written as a product of 2's and 5's Number of zeros = a ;where 'a' is (5*2)^a The exponent of 5 in 1000! is
1000/5 + 1000/25 + 1000/125 + 1000/625(rounds off to 1 )
= 200+40+8+1=249 Since 1000! Has more 2 exponents than 5 , the limiting number will be 5. Hence 1000! Will have 249 zeros Hope you found it easy:)
I have no idea but use a C++ program to solve it. The sourse code is following.
using namespace std;
int main()
{
int n,a[MAX];
int i,j,k,count,temp;
while(cin>>n)
{
a[0]=1;
count=1;
for(i=1;i<=n;i++)
{
k=0;
for(j=0;j<count;j++)
{
temp=a[j]*i+k;
a[j]=temp%10;
k=temp/10;
}
while(k)
{
a[count++]=k%10;
k/=10;
}
}
for(j=MAX-1;j>=0;j--)
if(a[j])
break;
for(i=count-1;i>=0;i--)
cout<<a[i];
cout<<endl;
}
return 0;
}
Then we count these trailing zeroes and the problem can be solve.
More rudimentary form of Chew's solution. We know or observe that the trailing 0s are generated by multiples of 5 and only multiples of 5. Then: 1 0 0 0 ! = X ∗ 5 1 0 0 0 / 5 ∗ ( 1 0 0 0 / 5 ) ! = X ∗ 5 2 0 0 ∗ 2 0 0 ! , where X is the product of all numbers that don't divide by 5 We continue this method for the subsequent factorials: 1 0 0 0 ! = X ∗ 5 2 0 0 ∗ 2 0 0 ! = X ∗ Y ∗ 5 2 0 0 ∗ 5 4 0 ∗ 4 0 ! 1 0 0 0 ! = X ∗ 5 2 0 0 ∗ 2 0 0 ! = X ∗ Y ∗ 5 2 0 0 ∗ 5 4 0 ∗ 4 0 ! = X ∗ Y ∗ Z ∗ 5 2 0 0 ∗ 5 4 0 ∗ 5 8 ∗ 8 ! 1 0 0 0 ! = X ∗ 5 2 0 0 ∗ 2 0 0 ! = X ∗ Y ∗ 5 2 0 0 ∗ 5 4 0 ∗ 4 0 ! = X ∗ Y ∗ Z ∗ 5 2 0 0 ∗ 5 4 0 ∗ 5 8 ∗ 8 ! = X ∗ Y ∗ Z ∗ W ∗ 5 2 0 0 ∗ 5 4 0 ∗ 5 8 ∗ 5 1 ∗ 1 ! Finally you add the power of 5 and you get the number of trailing zeros: 2 0 0 + 4 0 + 8 + 1 = 2 4 9
Problem Loading...
Note Loading...
Set Loading...
The Trailing Number of Zeros of n ! is given by:
z ( n ) = ⌊ 5 n ⌋ + ⌊ 5 2 n ⌋ + ⌊ 5 3 n ⌋ + ⌊ 5 4 n ⌋ + . . .
where ⌊ ⌋ is the greatest integer function.
For example, for 1 3 ! : z ( 1 3 ) = ⌊ 5 1 3 ⌋ = 2
This is because a trailing 0 is formed by a factor of 1 0 = 2 ⋅ 5 , but there are always more 2's than 5's in the factorial, so we just need to count the number of powers of 5 in the product.
Similarly, for 1 0 0 0 ! :
z ( 1 0 0 0 ) = ⌊ 5 1 0 0 0 ⌋ + ⌊ 2 5 1 0 0 0 ⌋ + ⌊ 1 2 5 1 0 0 0 ⌋ + ⌊ 6 2 5 1 0 0 0 ⌋ = 2 0 0 + 4 0 + 8 + 1 = 2 4 9