(This is OEIS A057531.)
Your task
Given a positive integer, \$n\$, find the \$n\$th number where the digit sum equals the number of factors
Explanation
For example, let's take 22:
Its factors are \$[1, 2, 11, 22]\$ (length: 4).
Its digit sum is 4.
This means that it is a number where the digit sum equals the number of factors.
The series
The first few terms of this series are:
\$[1, 2, 11, 22, 36, 84, 101, 152, 156, 170]\$
Test cases
Note: these are 1-indexed. You may use 0-indexing.
Input Output 1 1 2 2 3 11 4 22 5 36 10 170 20 444 30 828 40 1111 50 1548 100 3588 Clarifications
- You may use either 0-indexing or 1-indexing
- The sequence starts from 1, not from 0
- The factors of a number include 1 and the number itself
- Default sequence rules apply - you may output the first \$n\$ terms, or the infinite sequence, or something else
- This is code-golf, so shortest answer in bytes wins!
I have some Python solutions that I'll post in a few days if they don't get beaten:
- 88 bytes for the infinite sequence
- 92 bytes for the \$n\$th term
- 126 bytes for the first \$n\$ terms