# Problem Code: **FCTRL**

# Factorial

My code failed to pass this test case …when n = 8735373

#include<bits/stdc++.h>

using namespace std;

int multiply(int size,int *arr,int n)

{

int carry = 0;

for(int x=0;x<size;x++)

{

int prod = (arr[x] * n) + carry;

arr[x] = prod % 10;

carry = prod / 10;

}

while(carry)

{

arr[size] = carry % 10;

carry = carry / 10;

size++;

}

return size;

}

int main()

{

int t;

cin>>t;

while(t–)

{

long long n;

cin>>n;

int *arr;

arr = new int[1000000];

arr[0] = 1;

int size = 1;

for(int i=2;i<=n;i++)

{

size = multiply(size,arr,i);

}

for(int i=0;i<size;i++)

{

if(arr[i] != 0)

{

cout<<i<<endl;

break;

}

}

delete []arr;

}

}