I'm trying to print Ackermann's function values in C++
the first 50 results are right but as the number starts to grow out the last digit start to be printed wrongly.
for example:
// consider ack(m, n) as the ackermann function
case ack(3, 51) should print 18014398509481981 but instead it prints 18014398509481980. The diffence is always between 1 and 3 on the last digit case ack(3, 175) should print 383123885216472214589586756787577295904684780545900544 and it prints 383123885216472214589586756787577295904684780545900541.
i'm trying to print these giant numbers without storing then into a variable because i don't know any native cpp datatype that can store such big numbers so i instead printed the value directly like that:
cout << setprecision(0) << fixed << (8*pow(2,n)-3) << "\n";
what can i do to print the right value? can i do it differently?