Skip to content

2081. Sum of k-Mirror Numbers #1842

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to find the sum of the n smallest k-mirror numbers. A k-mirror number is a positive integer that reads the same both forward and backward in both base-10 and base-k. The solution involves generating palindromic numbers in base-10 and checking if they are also palindromic in base-k.

Approach

  1. Generate Palindromic Numbers in Base-10:

    • We generate palindromic numbers in increasing order by their digit lengths. For each digit length L:
      • Even Length (L is even): The palindrome is formed by concatenating a number x with its reverse. For example, if x is 12, the palindrome is 1221.
      • Odd Length (L is odd): The palindrome is formed by concatenating a number x with the reverse of x without …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@topugit
Comment options

topugit Jun 23, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim Jun 23, 2025
Maintainer Author

Answer selected by topugit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested hard Difficulty
2 participants