• + 0 comments

    for this case you can check for d>n and d = d%n then d will be in range of 0 to n and the above solution will work perfectly :)