Multiply 3 and Add 5: The program must accept an integer N as the input. The program must print YES if it is possible to form the integer N based on the following conditions.
– The initial value must be 3 or 5.
– Then it can be modified using the following two operations.
Operation 1: Multiply by 3
Operation 2: Add 5
If it is not possible, the program must print NO as the output.
3 <= N <= 10^8
The first line contains N.
The first line contains YES or NO.
Example Input/Output 1:
Here N = 19.
The only possible way to form 19 is 3 * 3 + 5 + 5.
So YES is printed as the output.
Example Input/Output 2:
a=int(input()) while a>0: if a==3 or a==5: print("YES") break if a%3==0: a//=3 else: a-=5 else: print("NO")