Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def show_rest_palindrome(my_number, limit=100, print_calc=False):
- my_number = str(my_number)
- loop = 1
- last_rest = int(my_number)%int(my_number[::-1])
- last_change = 0
- for i in range(1, limit):
- palindrom = int(my_number[::-1])
- multiplied_digits = my_number * i
- number = int(multiplied_digits)
- quotient = number//palindrom
- rest = number%palindrom
- #print(f"{rest} ({type(rest)}), {last_rest} ({type(last_rest)})")
- if rest != last_rest:
- last_change = loop
- if print_calc:
- if limit <= 10:
- print(f"{number} ÷ {palindrom} = {quotient} R {rest}")
- else:
- print(f"Loop {loop}: R = {rest}")
- last_rest = rest
- loop += 1
- print(f"Last change of rest for {my_number} with {limit-1} loops at loop #{last_change}.")
- show_rest_palindrome(my_number=23, print_calc=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement