A self-dividing number is a number that is divisible by every digit it contains and contains no zero digit. Return a list of every self-dividing number in the inclusive range from left to right, in ascending order.

Examples:

Input: left = 1, right = 22 Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22] Explanation: Single-digit numbers are always self-dividing. 11 is divisible by 1. 12 is divisible by 1 and 2. 15 is divisible by 1 and 5. 22 is divisible by 2 and 2. Input: left = 47, right = 85 Output: [48, 55, 66, 77] Explanation: 48 is divisible by 4 and 8. 55 is divisible by 5 and 5. 66 is divisible by 6 and 6. 77 is divisible by 7 and 7. Input: left = 10, right = 10 Output: [] Explanation: 10 contains the digit 0, so it cannot be self-dividing. Input: left = 15, right = 15 Output: [15] Explanation: 15 is divisible by 1 and 5, so it is self-dividing.
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay September 2026 (Sep 16–30)Sponsored by FLXBL

Contest runs September 16 - 30. Complete challenges to climb the leaderboard!

1st & 2nd: Salesforce certification exam voucher see all prizes

Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In