Find unit digit of x raised to power y | find unit digit ; Get last digit of x ; Last cyclic modular value ; here we simply return the unit digit or the power of a number ; Driver code ; get unit digit number here we pass the unit digit of x and the last cyclicity number that is y % 4
< ? php function unitnumber ( $ x , $ y ) { $ x = $ x % 10 ; if ( $ y != 0 ) $ y = $ y % 4 + 4 ; return ( ( ( int ) ( pow ( $ x , $ y ) ) ) % 10 ) ; } $ x = 133 ; $ y = 5 ; echo ( unitnumber ( $ x , $ y ) ) ; ? >