×

FCTRL Error

 0 Here is my code for the problem where we need to find the number of trailing zeros in the factorial of a given number. Link here #include using namespace std; long long z(long long a) {//number of trailing zeroes in a! int sum=0,t,b=1; while(t!=0) { t=a/pow(5,b); b++; sum=sum+t; } return sum; } int main() { long long t,a; cin>>t; while(t--) { cin>>a; cout<

 1 You are not initializing t . t can be 0 initially and so it will not go in the loop . Here is your corrected code . #include using namespace std; long long z(long long a) {//number of trailing zeroes in a! int sum=0,t=1,b=1; while(t!=0) { t=a/pow(5,b); b++; sum=sum+t; } return sum; } int main() { long long t,a; cin>>t; while(t--) { cin>>a; cout<
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,901
×45

question asked: 24 May '14, 13:36

question was seen: 735 times

last updated: 24 May '14, 14:28