• + 0 comments

    I used this recursive code but not passing all test cases:

    def hrank(x, k):
        if 0 <= x < k:
            return 1
        elif (x >= k) and (x % k == 0):
            return (hrank(x - k, k) + hrank(x / k, k))
        else:
            return hrank(x-1, k)
    
    
    k, x = map(int, raw_input().split()) 
    
    print hrank(x, k)