FCTRL2

FCTRL2

#include<iostream>

#include<cstring>

int max = 5000;

void display(int arr[]){
    int ctr = 0;
    for (int i=0; i<max; i++){
        if (!ctr && arr[i])                     ctr = 1;
        if(ctr)
            std::cout<<arr[i];
    }
}


void factorial(int arr[], int n){
    if (!n) return;
    int carry = 0;
    for (int i=max-1; i>=0; --i){
        arr[i] = (arr[i] * n) + carry;
        carry = arr[i]/10;
        arr[i] %= 10;
    }
    factorial(arr,n-1);
}

int main(){
   
    int t;
    std::cin>>t;
    for(int j=0;j<t;j++){
            int *arr = new int[max];
    std::memset(arr,0,max*sizeof(int));
    arr[max-1] = 1;
    int num;
    std::cin>>num;
    factorial(arr,num);
    display(arr);
    std::cout<<"\n";
    delete[] arr;
}
   
    return 0;
}


FCTRL

FCTRL

#include<iostream>

#include<math.h>
using namespace std;

main()

{
      long int a,b,d,g,x,e,f,sum;
      long int c[100000];
  cin>>a;
  for(b=0;b<a;b++)
  {
                  cin>>c[b];   
      }
     
      for(b=0;b<a;b++)
      {
                      sum=0;
                      e=0;
                      f=1;
                      x=c[b];
                      g=pow(5,f);
                      while(x/g>0)
                      {
                                sum=sum+x/g;
                               
                                f++;        
                                g=pow(5,f);                             
                                          }
     
                     cout<<sum<<endl;
                   
                     
                      }

}