(n)
| 1 | var IsGood = function (n) { |
| 2 | let result = false; |
| 3 | while (n > 0) { |
| 4 | // Checking the last digit of the number by mod 10 |
| 5 | let digit = n % 10; |
| 6 | // ignore 0, 1, 8; by themselves, no change |
| 7 | if (digit === 3 || digit === 4 || digit === 7) return false; |
| 8 | if (digit === 2 || digit === 5 || digit === 6 || digit === 9) result = true; |
| 9 | // excluding the last digit |
| 10 | n /= 10; |
| 11 | } |
| 12 | return result; |
| 13 | }; |
| 14 | |
| 15 | var rotatedDigits = function (N) { |
| 16 | let count = 0; |