How to Get Last Digit of a Large Number in C
The challenge
Define a function that takes in two non-negative integers aa_a_ and bb_b_ and returns the last decimal digit of aba^b_a__b_. Note that aa_a_ and bb_b_ may be very large!
For example, the last decimal digit of 979^797 is 999, since 97=47829699^7 = 478296997=4782969. The last decimal digit of (2200)2300({2^{200}})^{2^{300}}(2200)2300, which has over 109210^{92}1092 decimal digits, is 666. Also, please take 000^000 to be 111.
You may assume that the input will always be valid.
Examples:
The solution in C
Option 1:
|
|
Option 2:
|
|
Option 3:
|
|
Test cases to validate our solution
|
|