Ctrl K

A Mirror in Every Base

Medium
Call an integer number mirrored in all bases if, written in every base from 2 to number - 2 inclusive, its digits read the same left to right and right to left. Return True if number is mirrored in all bases and False otherwise. Checking every base directly works, but think about whether you can answer without computing anything at all.
Example 1
number=7 → False

In base 2, 7 = 111, a palindrome, but in base 3, 7 = 21, which is not.

Example 2
number=4 → False

Only base 2 needs checking: 4 = 100, not a palindrome.

Constraints
  • 4 ≤ number ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsRoll an Array to the Right MediumLamps Left Burning MediumSorted Parabola Values MediumNext Bigger From the Same Digits MediumTwo Squares Make It Medium
loading Python…
Input
number=7
Expected
False

Run checks the first 3 tests in your browser. Submit checks all 58 tests on the server, hidden ones included.