I need program whiCH ables to calculates the factorial of 200 (200!). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need program whiCH ables to calculates the factorial of 200 (200!).

I tried below program with unsigned long long but still 200! is more than that so I am getting 0 as output. #include<iostream> using namespace std; int num; int factorial(int n) { if (n==1) { return 1; } else { return n * factorial(n-1); } } int main() { cin >> num; cout << factorial(num); }

7th Dec 2017, 2:22 AM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar
4 Answers
+ 3
7th Dec 2017, 3:55 AM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar
+ 5
You could use a vector<int> to make your own "BigNum" class. So instead of int=19345 you would have vector <int> {1, 9, 3, 4, 5}. Then you would have to define multiplication for these BigNum objects.
7th Dec 2017, 2:33 AM
Eric Blinkidu
Eric Blinkidu - avatar
+ 4
Wow, you did it! Excellent!
7th Dec 2017, 5:12 AM
Eric Blinkidu
Eric Blinkidu - avatar
7th Dec 2017, 6:16 AM
#RahulVerma
#RahulVerma - avatar