Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- def digit_reverse(N):
- return int(str(N)[::-1])
- def test(N, n):
- """ Test if a = (N digit-reversed) fulfils n*N = a """
- return n*N == digit_reverse(N)
- def search_smallest(n):
- # Obiously, it works for 0...
- N = 1
- while not test(N, n):
- N += 1
- return N
- if __name__ == '__main__':
- from argparse import ArgumentParser
- parser = ArgumentParser()
- # Add more options if you like
- parser.add_argument("-n", "--multiplier", dest="n", default="9", type=int)
- args = parser.parse_args()
- print(search_smallest(args.n))
Add Comment
Please, Sign In to add comment