+ 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 :)
3 Antworten
+ 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.
+ 1
Thanks for the quick respond.
Yeah I meant factorial 😅 Will try this out. Have a nice weekend ✌
+ 1
It worked. Thanks a lot. Very helpful 😊