Skip to content

Practice Powerful Integers

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#970
LeetCode Problem

Powerful Integers

Problem Statement

Given x, y, and bound, return every distinct integer at most bound expressible as x^i + y^j for nonnegative integers i and j. Each result appears only once; output order is arbitrary.

Source: Powerful Integers on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
x = 2, y = 3, bound = 10
Output
[2,3,4,5,7,9,10]

# Example 2

Input
x = 3, y = 5, bound = 15
Output
[2,4,6,8,10,14]

Constraints

1 <= x, y <= 100
0 <= bound <= 10^6

Related LeetCode Problems

Practice more problems similar to Powerful Integers.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.