Our today's Programming Problem is quite easier . It uses your Basic mathematics skill of School level But Really This Problem Test your skills .
You Have to Find Number of Zeros at end of factorial of a number without using real factorisation
example : let No be 15 then 15 ! (15 factorial ) =1*2*3* ..........*13*14*15
and you have to find out number of Zero's at end of 15 ! = 3
as 15!=1307674368000 .
I Gave you some results to check your Program output . So hurry Up .
Related Post : Make your browsing faster
Solve This problem And Share your Code (try to use codepad.org link ) or Logic To improve your and our Logic for this Code .
Now solve This Problem :
Now Think when you get a 0 in factorial of any number . that is obvious when we encounter 5 or multiple of 5 multiply by even number (here we neglect number like 10,20,30 .. because they are also multiple of 5 ).
Now even no are more frequent come than 5 or multiple of five so our main concern is 5 not even number .
Think about How you exploit this 5. I am going to tell how I exploit But may be you find some better way to exploit it .If you found please share it with Us .
Related Post : Audible welcome note using Vbs script
Now check Out This simple code for better understanding .
Now Check Out these C and Python pRogram :
OutPut is Like This :
Output Is same as for Python : that is obvious ..
Related Post :
How to free your Browser from unwanted search extensions
Hope you Enjoy . If You found some better algorithm please share .
You Have to Find Number of Zeros at end of factorial of a number without using real factorisation
example : let No be 15 then 15 ! (15 factorial ) =1*2*3* ..........*13*14*15
and you have to find out number of Zero's at end of 15 ! = 3
as 15!=1307674368000 .
I Gave you some results to check your Program output . So hurry Up .
Related Post : Make your browsing faster
NUMber (N)

No of Zero at end of N!

100

24

1024

253

23456

8735373

45

10

120

28

1234

305

Solve This problem And Share your Code (try to use codepad.org link ) or Logic To improve your and our Logic for this Code .
Now solve This Problem :
Now Think when you get a 0 in factorial of any number . that is obvious when we encounter 5 or multiple of 5 multiply by even number (here we neglect number like 10,20,30 .. because they are also multiple of 5 ).
Now even no are more frequent come than 5 or multiple of five so our main concern is 5 not even number .
Think about How you exploit this 5. I am going to tell how I exploit But may be you find some better way to exploit it .If you found please share it with Us .
Related Post : Audible welcome note using Vbs script
Algorithm :
 Now let the Number is N .
 Divide N by 5 and Note quotient (only integer part ) Ex: 62/5 = 12 (require quotient .) .
 Now divide N by 5^2 =25 and again note quotient .
 again divide N By 5^3=125 and again note quotient .
 divide Until 5^n greater than N.
 Sum of all quotient is Our required RESULT .
a = input
b=5
while(b<a)
{
count=count
+ a/b; // a/b is integer
b=b*5;
}
Print(count)

Now Check Out these C and Python pRogram :
Python 3.3.0 Code:
tst=int(input()) ##
No of Test Case
while(tst): ## to solve each test case
count=0
b=5 ##intialise
a=int(input())
while(b<=a): ## condition to break loop
count=count+(a//b)
b=b*5
print(count) ## print result
tst=tst1
tst=int(input()) ##
No of Test Case
while(tst): ## to solve each test case
count=0
b=5 ##intialise
a=int(input())
while(b<=a): ## condition to break loop
count=count+(a//b)
b=b*5
print(count) ## print result
tst=tst1
OutPut is Like This :
C CODE :
#include<stdio.h>
main()
{
int tst,count;
long long int b,a;
printf("enter No of Test Case : ");
scanf("%d",&tst); // No of Test Case
while(tst)
{
printf("insert N : ");
scanf("%lld",&a);
count=0;
b=5;
while(b<=a)
{
count=count+a/b;
b*=5;
}
printf("%d\n",count);
}
return 0;
}
Output Is same as for Python : that is obvious ..
Related Post :
How to free your Browser from unwanted search extensions
its easy first find the fictorial of number enter by user then store in array.
ReplyDeletethen check from the last with count when a non zero no come its break
WAQAR : It is OUR first condition that we have to find no of Zero's without finding its factorial . because let assume Number is very large i.e order of 10^7 Than it takes very large time & also your data type can't hold this big data .
DeleteHmmm... a first idea is to divide each element of the factorial into its prime and then count the pairs of primes that form 10 (basically how often can the pair (2,5) be build from the elements)
ReplyDeleteI Don't think that This is very good IDEA . i think it is too lengthy even then i am not sure about correct answer .
Deleteanyway answer is posted NOW
It is appropriate time to make a few plans for the longer term and it is time to be happy.
ReplyDeleteI've read this put up and if I may just I want to recommend you few attentiongrabbing things or tips.
Perhaps you can write next articles referring to this article.
I desire to read even more issues approximately it!
Also visit my website; Beats By Dre
I'm very happy to uncover this site. I want to to thank you
ReplyDeletefor ones time just for this fantastic read!! I definitely really liked every bit of it and i also have you saved to fav to look at
new stuff in your website.
Here is my site; Christian Louboutin Online