Lucky Division
Practice this coding question on Coding Gurukul.
Problem statement
A festival warehouse sells identical gift packs. Its special packaging machine accepts only pack sizes written entirely with the digits 4 and 7. Before loading a shipment of n gifts, the operator must decide whether one allowed pack size can divide the shipment without leaving any gifts unpacked. Your task Determine whether n is divisible by at least one positive integer whose decimal digits are all 4 or 7. Important details The pack size may contain several digits and may equal n. Every pack in a shipment uses the same size. Having a 4 or 7 somewhere in n does not by itself qualify the shipment, and divisibility by ordinary primes is not the rule. Worked example For n = 94, choose packs of size 47: two packs use all gifts, so print YES. For n = 13, no allowed size divides the shipment, so print NO. A shipment of 7 gifts is valid because one pack of size 7 is allowed.
Input format
Read one integer n.
Output format
Print YES if a valid pack size exists, otherwise NO.
Constraints
1 <= n <= 1000.
Sample input
94
Sample output
YES
Sign in to run or submit a solution in C++, Java or Python.