Suppose we have a positive number n, we have to find that we can make n by summing up some non-negative multiple of 3 and some non-negative multiple of 7 or not.
So, if the input is like 13, then the output will be True, as 13 can be written as 1*7+2*3 = 13
To solve this, we will follow these steps −
for i in range 0 to n+1, increase by 7, do
if n-i is divisible by 3, then
Let us see the following implementation to get better understanding −
class Solution: def solve(self, n): for i in range(0,n+1,7): if (n-i)%3 == 0: return True return False ob = Solution() print(ob.solve(13))