This Python program reads an integer and checks whether its digits, from right to left, decrease by 4 in each adjacent pair.
If the condition holds, it prints Yes; otherwise, it prints No.
def check_decreasing_by_4(num: int) -> str:
digits = [int(d) for d in str(num)][::-1] # right to left
for i in range(len(digits) - 1):
if digits[i + 1] - digits[i] != 4:
return "No"
return "Yes"
# Read input from user
n = int(input("Enter a number: "))
result = check_decreasing_by_4(n)
print(result)
Input: 35 → Output: Yes
Input: 25 → Output: Yes
Input: 15 → Output: Yes
Input: 45 → Output: No
Input: 5 → Output: Yes (only one digit)