Cody

Problem 2396. last n digit of a power function

Solution 1121616

Submitted on 12 Feb 2017 by Jihye Sofia Seo
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   Pass
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 = 43 res = 29 res = 87 res = 61

2   Pass
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 = 17649 res = 23543 res = 64801 res = 53607 res = 75249 res = 26743 res = 87201

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

4   Pass
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 = 1.5759e+20 res = 1.0291e+21 res = 3.3948e+20 res = 7.2242e+20 res = 4.8218e+21 res = 3.1538e+21 res = 2.1453e+21 res = 7.6049e+21 res = 5.4745e+20 res = 4.4460e+20 res = 1.4527e+21 res = 5.6635e+21 res = 9.5985e+21 res = 1.6375e+21 res = 7.5862e+21 res = 6.1702e+21 res = 8.6879e+21 res = 2.2840e+21 res = 4.1158e+21 res = 9.3705e+20 res = 9.6518e+21 res = 2.6187e+21 res = 1.1583e+21 res = 9.6093e+21 res = 9.9073e+21 res = 8.7919e+21 res = 2.2155e+21 res = 1.5286e+21 res = 3.9472e+21 res = 1.4765e+21 res = 3.9591e+21 res = 6.0428e+20 res = 4.0887e+21 res = 1.5291e+20 res = 7.4372e+21 res = 1.7609e+21 res = 2.3974e+21 res = 1.2121e+21 res = 8.8976e+20 res = 3.3325e+21 res = 9.3763e+21 res = 9.8245e+20 res = 4.5230e+21 res = 3.6352e+21 res = 1.8210e+21 res = 8.4935e+21 res = 3.0004e+21 res = 4.2779e+21 res = 5.4099e+21 res = 4.8293e+21 res = 8.8671e+21 res = 9.9614e+21 res = 3.1758e+20 res = 3.9016e+21 res = 6.4283e+21 res = 6.9708e+21 res = 3.6081e+21 res = 9.8640e+20 res = 7.5556e+21 res = 2.6870e+21 res = 3.5912e+21 res = 8.0147e+21 res = 5.2977e+21 res = 8.6223e+21 res = 1.8958e+21 res = 5.9959e+21 res = 4.8205e+21 res = 2.1379e+21 res = 1.9436e+21 res = 2.6704e+21 res = 8.9779e+20 res = 9.5065e+21 res = 9.8327e+20 res = 5.1481e+21 res = 3.7210e+21 res = 7.7605e+21 res = 7.8747e+19 res = 4.7785e+20 res = 6.9886e+21 res = 7.2078e+21 res = 5.6243e+21 res = 9.4282e+21 res = 8.7630e+20 res = 2.9952e+21 res = 2.9664e+20 res = 7.8182e+21 res = 4.3816e+21 res = 5.0704e+21 res = 4.0406e+21 res = 3.1425e+21 res = 3.4684e+21 res = 3.7239e+21 res = 9.9213e+21 res = 9.5706e+21 res = 2.2785e+20 res = 4.9852e+21 res = 8.6709e+21 res = 9.2717e+21 res = 7.0171e+20 res = 8.9098e+21 res = 2.6953e+21 res = 2.8511e+19 res = 1.8966e+21 res = 6.6125e+21 res = 8.4060e+21 res = 5.8446e+21 res = 8.6474e+21 res = 1.1956e+21 res = 8.1853e+21 res = 6.3348e+21 res = 5.1639e+21 res = 5.8637e+21 res = 3.2939e+21 res = 9.7020e+21 res = 1.1223e+21 res = 1.9398e+21 res = 9.7795e+21 res = 6.5734e+20 res = 4.8341e+21 res = 2.5705e+21 res = 4.1489e+21 res = 6.3322e+21 res = 3.1472e+21 res = 7.0539e+21 res = 7.4188e+21 res = 7.6512e+21 res = 6.1046e+21 res = 8.3312e+21 res = 8.3703e+21 res = 8.3995e+21 res = 8.0033e+20 res = 4.6518e+21 res = 2.5871e+21 res = 6.9142e+21 res = 1.4083e+20 res = 8.1593e+21 res = 6.3718e+21 res = 3.5614e+21 res = 5.1309e+21 res = 5.4309e+20 res = 7.0944e+21 res = 8.5295e+21 res = 6.6584e+20 res = 1.3635e+21 res = 7.1440e+21 res = 6.5774e+21 res = 1.4200e+21 res = 5.8674e+20 res = 6.1955e+20 res = 5.8113e+21 res = 3.0803e+21 res = 5.6555e+21 res = 3.4166e+21 res = 3.9475e+21 res = 1.6764e+21 res = 7.4761e+21 res = 1.6347e+21 res = 5.4257e+21 res = 6.9159e+21 res = 1.4238e+21 res = 3.4555e+21 res = 3.7904e+21 res = 1.0303e+21 res = 1.2487e+21 res = 9.0150e+21 res = 3.5410e+21 res = 9.4896e+21 res = 8.0137e+21 res = 4.5205e+21 res = 1.7719e+21 res = 8.4024e+20 res = 5.3049e+21 res = 4.1406e+21 res = 9.9826e+21 res = 6.6645e+21 res = 8.3323e+21 res = 9.2292e+21 res = 8.0287e+21 res = 6.0554e+21 res = 5.7608e+20 res = 2.4257e+21 res = 2.9152e+21 res = 8.8408e+21 res = 9.7361e+21 res = 7.3081e+21 res = 2.5975e+21 res = 4.8793e+21 res = 7.3122e+21 res = 5.7640e+21 res = 6.7577e+21 res = 9.8901e+21 res = 5.5707e+21 res = 8.2816e+21 res = 2.5815e+20 res = 8.2609e+21 res = 4.3492e+21 res = 1.5397e+20 res = 8.2512e+21 res = 6.9147e+21 res = 5.1085e+20 res = 2.3338e+21 res = 2.3286e+21 res = 8.3949e+21 res = 7.2820e+21 res = 2.5680e+21 res = 2.2430e+21 res = 2.6583e+21 res = 1.5933e+21 res = 3.6917e+21 res = 5.2115e+21 res = 2.4444e+21 res = 7.2979e+21 res = 4.7555e+21 res = 2.2309e+21 res = 3.3114e+21 res = 3.1513e+21 res = 2.1587e+20 res = 5.7856e+21 res = 3.3061e+21 res = 9.1223e+21 res = 5.9159e+21 res = 3.4187e+21 res = 5.5538e+21 res = 5.3402e+21 res = 1.2428e+21 res = 4.4617e+21 res = 6.6240e+21 res = 7.1977e+21 res = 7.8521e+21 res = 3.7910e+20 res = 1.1461e+21 res = 1.9519e+20 res = 9.9092e+21 res = 2.8075e+20 res = 5.6139e+21 res = 1.4481e+21 res = 2.1091e+21 res = 9.7896e+21 res = 8.4294e+21 res = 3.7799e+21 res = 2.9964e+21 res = 1.2185e+21 res = 5.8013e+21 res = 5.3848e+21 res = 5.5254e+21 res = 3.5168e+21 res = 9.1871e+20 res = 5.5697e+21 res = 7.5642e+21 res = 9.2886e+21 res = 3.6816e+21 res = 7.4809e+21 res = 5.3658e+21 res = 9.5960e+20 res = 6.9718e+21 res = 4.3699e+21 res = 6.1022e+21 res = 6.4841e+21 res = 9.8037e+21 res = 9.2768e+21 res = 4.5761e+21 res = 4.4329e+21 res = 4.4940e+21 res = 1.3898e+21 res = 7.4043e+21 res = 6.4857e+21 res = 1.0393e+21 res = 8.1881e+21 res = 8.4894e+21 res = 9.8750e+21 res = 3.9885e+21 res = 3.1845e+21 res = 5.6781e+21 res = 7.8391e+20 res = 2.0404e+21 res = 7.0616e+21 res = 3.3329e+21 res = 9.6943e+21 res = 5.1922e+21 res = 7.6332e+21 res = 2.3292e+21 res = 8.8090e+21 res = 5.3044e+21 res = 3.7642e+21 res = 9.2128e+20 res = 7.5394e+21 res = 2.3770e+20 res = 2.5524e+21 res = 2.1126e+20 res = 2.2475e+21 res = 6.0548e+21 res = 1.0389e+20 res = 9.7898e+21 res = 8.5716e+21 res = 2.9642e+21 res = 6.5309e+21 res = 5.7114e+21 res = 6.3353e+21 res = 5.5179e+21 res = 7.7572e+21 res = 7.5076e+21 res = 5.8501e+21 res = 2.8551e+21 res = 2.7430e+21 res = 6.6380e+21 res = 7.9653e+21 res = 7.3141e+21 res = 7.2250e+21 res = 8.8230e+21 res = 6.1020e+21 res = 6.3104e+21 res = 6.4197e+21 res = 3.0511e+20 res = 4.3227e+21 res = 9.8070e+21 res = 1.7532e+21 res = 6.4308e+21 res = 8.8422e+21 res = 7.7208e+20 res = 2.9600e+21 res = 3.2537e+21 res = 8.8744e+21 res = 5.5459e+21 res = 9.2348e+21 res = 2.3098e+21 res = 3.9346e+21 res = 1.8020e+21 res = 3.9304e+21 res = 8.5238e+21 res = 6.2768e+21 res = 6.1063e+20 res = 8.9643e+21 res = 4.5659e+21 res = 6.6442e+21 res = 2.7735e+21 res = 3.2665e+19 res = 5.0866e+21 res = 6.5429e+21 res = 4.9145e+21 res = 4.3285e+21 res = 4.3209e+21 res = 8.4174e+21 res = 4.5718e+21 res = 1.1247e+21 res = 3.7682e+21 res = 4.0137e+21 res = 2.5452e+21 res = 4.7086e+21 res = 6.2219e+21 res = 8.4529e+21 res = 1.8114e+21 res = 1.1478e+21 res = 1.5374e+21 res = 7.1904e+20 res = 2.2235e+21 res = 7.6190e+21 res = 1.4036e+21 res = 7.9763e+21 res = 5.7656e+21 res = 7.9534e+21 res = 8.2018e+21 res = 8.9780e+21 res = 5.1342e+21 res = 3.0339e+21 res = 1.0962e+19 res = 8.4188e+21 res = 5.6668e+21 res = 2.1265e+21 res = 3.1471e+21 res = 6.9973e+21 res = 3.9369e+21 res = 3.5397e+21 res = 8.5011e+21 res = 8.8183e+21 res = 2.4773e+21 res = 2.5802e+21 res = 1.5705e+21 res = 6.1535e+21 res = 5.8906e+21 res = 4.0126e+21 res = 1.6655e+21 res = 9.1092e+21 res = 5.8431e+21 res = 7.5345e+21 res = 6.5000e+21 res = 2.0155e+21 res = 7.9304e+21 res = 5.4358e+20 res = 7.4700e+21 res = 6.9517e+21 res = 8.9389e+21 res = 5.1062e+21 res = 1.5565e+21 res = 5.3586e+21 res = 5.4140e+21 res = 7.9312e+21 res = 1.1833e+21 res = 8.7636e+21 res = 4.7619e+20 res = 5.7119e+21 res = 6.7016e+21 res = 6.8520e+21 res = 2.3123e+21 res = 5.8212e+21 res = 6.6805e+20 res = 3.0618e+21 res = 1.4928e+21 res = 6.4348e+21 res = 1.9299e+21 res = 2.1641e+21 res = 2.0483e+21 res = 3.1041e+21 res = 3.9303e+21 res = 8.5024e+21 res = 9.8607e+21 res = 3.0193e+21 res = 8.7960e+21 res = 5.3232e+21 res = 8.1980e+21 res = 6.0806e+21 res = 9.8731e+21 res = 2.5143e+21 res = 9.4510e+20 res = 5.8381e+21 res = 3.6324e+21 res = 9.6954e+21 res = 6.0492e+21 res = 5.7688e+21 res = 4.7079e+20 res ...

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!