+ 1

Cannot get recursive function to get faculties for n higher 15

So i wrote a code to calculate the faculty of an integer recursevely. So far it only works for integers up to 15 because of the length it can have. Instead i tried to use long but that did not allow higher numbers n. Have you any idea how to overcome this? https://code.sololearn.com/cBsIeJnpfQze/#cpp Thanks for you help :)

30th Sep 2017, 3:10 PM
Falkao
Falkao - avatar
3 Respostas
+ 4
By faculty do you mean factorial? 😛 Try an unsigned long long instead of int. That is as high as you will get before you will have to start using strings or a different notation to treat the numbers (Like Scientific notation). 'unsigned' means there is no negative numbers. This leaves an extra byte to allow for larger positive numbers.
30th Sep 2017, 4:25 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Thanks for the quick respond. Yeah I meant factorial 😅 Will try this out. Have a nice weekend ✌
30th Sep 2017, 4:32 PM
Falkao
Falkao - avatar
+ 1
It worked. Thanks a lot. Very helpful 😊
30th Sep 2017, 4:37 PM
Falkao
Falkao - avatar