1226 - Numerical surprises


Difficulty : trivial

Solution Description :

Remainder algorithm problem

input n & p. print (p%n)

For solve this you need to use remainder algorithm

suppose p=1011 and n=5
set m=0

m = (m*10 + 1st digit of p)%n = (0*10 + 1)%5 = 1
m = (m*10 + 2nd digit of p)%n = (1*10 + 0)%5 = 0
m = (m*10 + 3rd digit of p)%n = (0*10 + 1)%5 = 1 
m = (m*10 + 4th digit of p)%n = (1*10 + 1)%5 = 1

so output 1