Last digit of Product of two Large or Small numbers ( a * b ) | Function to print last digit of product a * b ; Driver code
< ? php function lastDigit ( $ a , $ b ) { $ lastDig = ( ord ( $ a [ strlen ( $ a ) - 1 ] ) - 48 ) * ( ord ( $ b [ strlen ( $ b ) - 1 ] ) - 48 ) ; echo $ lastDig % 10 ; } $ a = "1234567891233" ; $ b = "1234567891233156" ; lastDigit ( $ a , $ b ) ; ? >