Cody

# Problem 2396. last n digit of a power function

Solution 2050323

Submitted on 8 Dec 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
base = 3; expo = 8; n = 2; y_correct = 61; assert(isequal(lastndigit(base,expo,n),y_correct))

res = 3 res = 9 res = 27 res = 81 res = 243 res = 729 res = 2187 res = 6561

Assertion failed.

2   Fail
base = 7; expo = 12; n = 5; y_correct = 87201; assert(isequal(lastndigit(base,expo,n),y_correct))

res = 7 res = 49 res = 343 res = 2401 res = 16807 res = 117649 res = 823543 res = 5764801 res = 40353607 res = 282475249 res = 1.9773e+09 res = 1.3841e+10

Assertion failed.

3   Fail
base = 25; expo = 71; n = 15; y_correct = 896881103515625; assert(isequal(lastndigit(base,expo,n),y_correct))

res = 25 res = 625 res = 15625 res = 390625 res = 9765625 res = 244140625 res = 6.1035e+09 res = 1.5259e+11 res = 3.8147e+12 res = 9.5367e+13 res = 2.3842e+15 res = 5.9605e+16 res = 1.4901e+18 res = 3.7253e+19 res = 3.1323e+19 res = 8.3064e+19 res = 7.6609e+19 res = 1.5228e+19 res = 8.0709e+19 res = 1.7729e+19 res = 4.3232e+19 res = 8.0802e+19 res = 2.0040e+19 res = 1.0000e+18 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19 res = 2.5000e+19

Assertion failed.

4   Fail
base = 768; expo = 1579; n = 22; y_correct = 3750595090000885317632; assert(isequal(lastndigit(base,expo,n),y_correct))

res = 768 res = 589824 res = 452984832 res = 3.4789e+11 res = 2.6718e+14 res = 2.0520e+17 res = 5.7590e+19 res = 2.9088e+19 res = 3.9482e+19 res = 2.2424e+19 res = 2.1815e+19 res = 5.3835e+19 res = 4.5319e+19 res = 4.8795e+18 res = 4.7454e+19 res = 4.4600e+19 res = 5.2687e+19 res = 6.3540e+19 res = 9.8486e+19 res = 3.7482e+19 res = 8.6159e+19 res = 7.0166e+19 res = 8.7870e+19 res = 8.4005e+19 res = 1.5803e+19 res = 3.7047e+19 res = 5.1847e+19 res = 1.8696e+19 res = 5.8345e+19 res = 9.2543e+18 res = 7.2812e+18 res = 9.1947e+19 res = 1.5532e+19 res = 2.8577e+19 res = 4.7235e+19 res = 7.6509e+19 res = 5.9120e+19 res = 4.2822e+18 res = 8.8741e+19 res = 5.2913e+19 res = 3.7189e+19 res = 6.0934e+19 res = 9.7412e+19 res = 1.2096e+19 res = 8.9756e+19 res = 3.2521e+19 res = 7.6279e+19 res = 8.2452e+19 res = 2.2962e+19 res = 3.5184e+19 res = 2.0955e+19 res = 9.3490e+19 res = 3.6182e+17 res = 7.7878e+19 res = 9.9339e+18 res = 2.9254e+19 res = 6.7137e+19 res = 6.1351e+19 res = 1.7580e+19 res = 1.5994e+18 res = 2.8347e+19 res = 7.0844e+19 res = 8.0552e+18 res = 8.6400e+19 res = 5.5582e+19 res = 8.6968e+19 res = 9.1165e+19 res = 1.4711e+19 res = 9.7685e+19 res = 2.2260e+19 res = 9.5828e+19 res = 9.5860e+19 res = 2.0492e+19 res = 3.7947e+19 res = 4.3581e+19 res = 7.0440e+19 res = 9.7795e+19 res = 6.4886e+18 res = 8.3266e+19 res = 4.8074e+19 res = 2.1042e+19 res = 6.0519e+19 res = 7.8747e+19 res = 7.7850e+19 res = 8.8552e+19 res = 7.8441e+18 res = 2.4256e+19 res = 2.8224e+19 res = 7.6296e+19 res = 9.5178e+19 res = 9.6638e+19 res = 1.8205e+19 res = 8.1602e+19 res = 7.0365e+19 res = 4.0550e+19 res = 4.2537e+19 res = 6.8390e+19 res = 2.3856e+19 res = 2.1316e+19 res = 7.0609e+19 res = 2.7845e+19 res = 8.5249e+19 res = 7.0927e+19 res = 7.1747e+19 res = 1.7054e+18 res = 9.7596e+18 res = 9.5350e+19 res = 2.8511e+19 res = 9.6631e+19 res = 1.2508e+19 res = 6.0476e+18 res = 4.4593e+19 res = 4.7390e+19 res = 9.5554e+19 res = 8.5332e+19 res = 3.4849e+19 res = 6.3885e+19 res = 6.3664e+19 res = 9.3883e+19 res = 1.9822e+18 res = 2.2317e+19 res = 3.9817e+19 res = 7.9502e+19 res = 5.7336e+19 res = 3.4076e+19 res = 7.0506e+19 res = 4.8870e+19 res = 3.2223e+19 res = 4.7206e+19 res = 5.3931e+19 res = 1.8817e+19 res = 5.1178e+19 res = 4.5979e+18 res = 3.1211e+19 res = 7.0312e+19 res = 9.9480e+19 res = 3.2787e+17 res = 5.1806e+19 res = 8.7128e+19 res = 1.4246e+19 res = 4.0832e+19 res = 5.9338e+19 res = 7.1825e+19 res = 6.1368e+19 res = 3.0915e+19 res = 4.3092e+19 res = 9.4439e+19 res = 2.9513e+19 res = 6.5838e+19 res = 6.3469e+19 res = 4.3981e+19 res = 7.7370e+19 res = 2.0035e+19 res = 8.6744e+19 res = 1.9546e+19 res = 1.1302e+19 res = 8.0281e+19 res = 5.5490e+19 res = 1.6598e+19 res = 4.7495e+19 res = 7.6401e+19 res = 7.6087e+19 res = 3.4669e+19 res = 2.5672e+19 res = 1.5916e+19 res = 2.3770e+19 res = 5.5456e+19 res = 9.0404e+19 res = 3.0272e+19 res = 4.8717e+19 res = 1.5027e+19 res = 4.1002e+19 res = 8.9601e+19 res = 1.3699e+19 res = 2.0536e+19 res = 7.1927e+19 res = 4.0241e+19 res = 4.8706e+18 res = 4.0602e+19 res = 8.2636e+19 res = 6.4495e+19 res = 3.2330e+19 res = 2.9204e+19 res = 2.8718e+19 res = 5.5438e+19 res = 7.6075e+19 res = 2.5671e+19 res = 1.5157e+19 res = 4.0802e+19 res = 3.6078e+19 res = 8.0697e+18 res = 9.7499e+19 res = 7.9313e+19 res = 1.2193e+19 res = 6.4007e+19 res = 5.7669e+19 res = 9.0066e+19 res = 7.0679e+19 res = 8.1586e+19 res = 5.8152e+19 res = 6.0871e+19 res = 4.9159e+19 res = 5.3973e+19 res = 5.1191e+19 res = 1.4728e+19 res = 1.0851e+19 res = 3.3761e+19 res = 2.8639e+19 res = 9.4898e+19 res = 8.1990e+19 res = 6.8025e+19 res = 4.3045e+19 res = 5.8325e+19 res = 9.3349e+19 res = 9.1682e+19 res = 1.1516e+19 res = 4.4398e+19 res = 9.7859e+19 res = 5.5509e+19 res = 3.0874e+19 res = 1.1395e+19 res = 5.1323e+19 res = 1.5867e+19 res = 8.5555e+19 res = 6.1488e+18 res = 2.2286e+19 res = 1.5910e+19 res = 1.8690e+19 res = 5.3828e+19 res = 4.0160e+19 res = 4.2789e+19 res = 6.1750e+19 res = 2.3955e+19 res = 9.7724e+19 res = 5.2056e+19 res = 7.9096e+19 res = 4.6087e+19 res = 9.5194e+19 res = 9.2197e+18 res = 8.0747e+19 res = 1.3865e+19 res = 4.8059e+19 res = 9.1011e+18 res = 8.9622e+19 res = 2.9401e+19 res = 7.9943e+19 res = 9.6378e+19 res = 1.8491e+19 res = 1.2823e+18 res = 8.4799e+19 res = 2.5413e+19 res = 1.6821e+19 res = 1.8711e+19 res = 6.9745e+19 res = 6.4178e+19 res = 8.8648e+19 res = 8.1616e+19 res = 8.0945e+19 res = 6.5833e+19 res = 5.9599e+19 res = 7.1836e+19 res = 6.9925e+19 res = 2.1929e+18 res = 8.4119e+19 res = 3.7458e+18 res = 7.6792e+19 res = 7.6085e+19 res = 3.2935e+19 res = 9.3997e+19 res = 8.9849e+19 res = 4.2783e+18 res = 8.5728e+19 res = 3.9307e+19 res = 8.8137e+19 res = 8.9421e+19 res = 7.4985e+19 res = 8.8521e+19 res = 8.4477e+19 res = 7.8104e+19 res = 8.3907e+19 res = 4.0445e+19 res = 6.1631e+19 res = 3.2935e+19 res = 9.4261e+19 res = 9.2231e+19 res = 3.3241e+19 res = 2.9178e+19 res = 8.9901e+18 res = 4.3805e+18 res = 6.4220e+19 res = 2.1275e+19 res = 3.9372e+19 res = 3.7698e+19 res = 5.2358e+19 res = 1.1260e+19 res = 4.7467e+19 res = 5.4823e+19 res = 3.8930e+18 res = 8.9807e+19 res = 7.1568e+19 res = 6.4233e+19 res = 3.0874e+19 res = 1.1374e+19 res = 3.5310e+19 res = 1.7913e+19 res = 5.7171e+19 res = 7.6173e+18 res = 5.0072e+19 res = 5.5134e+19 res = 4.3018e+19 res = 3.7976e+19 res = 6.5253e+19 res = 1.4095e+19 res = 2.5030e+19 res = 2.3049e+19 res = 1.9667e+18 res = 1.0442e+19 res = 1.9668e+19 res = 5.1076e+18 res = 2.2665e+19 res = 6.9703e+18 res = 5.3165e+19 res = 3.0784e+19 res = 4.2151e+19 res = 7.2083e+19 res = 5.9966e+19 res = 5.3743e+19 res = 7.4409e+19 res = 4.5879e+19 res = 3.4778e+19 res = 9.8107e+18 res = 3.4638e+19 res = 1.9927e+18 res = 3.0370e+19 res = 2.3798e+19 res = 7.6837e+19 res = 1.0631e+19 res = 6.4279e+19 res = 6.5943e+19 res = 4.4236e+19 res = 7.3480e+19 res = 3.2665e+19 res = 8.6644e+19 res = 4.2857e+19 res = 1.4490e+19 res = 2.8543e+19 res = 2.0856e+19 res = 1.7411e+19 res = 7.1777e+19 res = 2.4698e+19 res = 6.8247e+19 res = 1.3731e+19 res = 4.5194e+19 res = 8.6223e+18 res = 2.1944e+19 res = 5.2879e+19 res = 1.1390e+19 res = 4.7835e+19 res = 3.7395e+19 res = 1.9041e+19 res = 2.3462e+19 res = 1.9015e+19 res = 3.6149e+18 res = 7.6257e+19 res = 6.5564e+19 res = 5.3388e+19 res = 1.7943e+18 res = 7.8039e+19 res = 3.4159e+19 res = 3.3868e+19 res = 1.0962e+19 res = 1.8837e+19 res = 6.6831e+19 res = 2.6494e+19 res = 4.7132e+19 res = 9.7314e+19 res = 3.6901e+19 res = 3.9715e+19 res = 1.0655e+18 res = 1.8330e+19 res = 7.7318e+19 res = 8.0170e+19 res = 7.0512e+19 res = 5.3503e+19 res = 9.0641e+19 res = 1.2585e+19 res = 6.5507e+19 res = 9.1708e+18 res = 4.3144e+19 res = 3.4505e+19 res = 2.0227e+16 res = 1.5534e+19 res = 3.0395e+19 res = 4.3581e+19 res = 6.9989e+19 res = 5.1743e+19 res = 3.8940e+19 res = 6.1933e+18 res = 5.6457e+19 res = 5.8612e+19 res = 1.3973e+19 res = 3.1228e+19 res = 8.3286e+19 res = 6.3641e+19 res = 7.6187e+19 res = 1.1851e+19 res = 1.6302e+18 res = 5.1969e+19 res = 1.2267e+19 res = 2.1182e+19 res = 6.8049e+19 res = 6.1840e+19 res = 9.2754e+19 res = 3.4805e+19 res = 2.9901e+19 res = 6.4125e+19 res = 4.8313e+19 res = 4.0760e+18 res = 3.0342e+19 res = 2.4228e+18 res = 6.0702e+19 res = 1.9266e+19 res = 9.5994e+19 res = 2.3175e+19 res = 9.8022e+19 res = 8.0564e+19 res = 7.3065e+19 res = 1.4251e+19 res = 4.5102e+19 res = 3.8063e+19 res = 3.2416e+19 res = 9.5377e+19 res = 4.9178e+19 res = 6.8842e+19 res = 7.0787e+19 res ...

Assertion failed.