I've been trying to calculate total of 1500th row in pascal triangle in c++.
I tried more than 6 different code snippets from all over the web.
Some of them crashed before 10th row, some gone crazy etc.
How can one achieve calculating total of numbers in 1500th row in pascal triangle.
I think there must be a formula to find a row without iterating over each row, because iterations causing program to crash.
The sum of the numbers in any row is equal to 2 ^ n
where n
is the row (starting at 0). So in your case, it would just be 1 << 1499
.
Your answer is the following:
17537331055217019373813793980140428996762007940165414412037899012395481925281661101828540443292484630826575203397718758699647274470734979877085519459002350423944978242664548632243401355791731473268341092170069314725677729132473171262691809694657480322332526275875721167754624586680565177898054854942790337156977105108828923716313380366502376637658596066837351781686391648520996613526331666834254976000087526677764529440217091269193357761841856604274688
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With