Skip to content
Onsite

Reach N by Multiplying by 10 or 20

EasyP3Coding

You start with exactly 1 rupee. You may apply two operations any number of times, in any order: multiply the amount by 10, or multiply it by 20. Return true if you can end with exactly n rupees, otherwise false.

Zero operations are allowed, so n = 1 is reachable.

Example 1

Input
n = 1
Output
true
Why
10 = 1 * 10.

Example 2

Input
n = 10
Output
true
Why
20 = 1 * 20.

Example 3

Input
n = 20
Output
true
Why
200 = 1 * 10 * 20.

Constraints

  • 1 <= n <= 10^15

Hints

Run checks the 3 visible tests, Submit all 12.