If n is a non-negative integer:
The last digit of n is n%10.
If n < 10, the first digit of n is n.
If n >= 10, the first digit of n is the first digit of n/10.
This is all you need to know in order to solve the problem.
Reputation Points: 359
Solved Threads: 109
Practically a Master Poster
Offline 680 posts
since Jun 2010