December 9, 2014, 2:38pm
# max 150 define
int T=0 ,n=0,i=0,j=0,k=0;
arr = 1;
out[k] = arr[j];
out[k] = 100;
x= arr[j]* i + temp;
arr[j] = x%10;
temp = x/10;
arr[j] = temp%10;
temp = temp /10 ;
my code works fine for even 400! but im getting and error of “Runtime Error(SIGSEGV)” while submmitting the answer can anybody plz help me out here and tell me what to be corrected ? …
I guess, 100! will need more than 150 digits… Try increasing the array size…
I don’t think so your code would be able to provide an output of 400! or even 100!.
See this :
Just observe this pic length of 100! is of 158 decimal numbers,
and as you are saying about 400!, its length is 869…
So there will definitely be a segmentation fault [SIGSEGV] as you have defined the array of MAXSIZE 150.
Just try uploading your code again by changing MAXSIZE to 200.
Best of Luck…!!
December 14, 2014, 4:23pm
Thanx for the idea freinds i just changed the size of “out” array to 7489(nearly rough idea) by for worst case scenario when test cases would be 100 and factorial is calculated. “arr” array size to 160 as
@rishabhprsd7 & @ajjinkya1p3 pointed out. and it worked fine.
If you think you got the answer then you may select the answer you like and close the thread…
Discussion forum is there to help everyone…