Skip to content

Practice Find the Punishment Number of an Integer

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

Medium#2698
LeetCode Problem

Find the Punishment Number of an Integer

Problem Statement

For each integer i from 1 through n, check whether the decimal digits of i^2 can be split into contiguous pieces whose integer values sum to i. Add i^2 for every passing value and return that sum, the punishment number of n.

Source: Find the Punishment Number of an Integer on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 10
Output
182

# Example 2

Input
n = 37
Output
1478

Constraints

1 <= n <= 1000

Related LeetCode Problems

Practice more problems similar to Find the Punishment Number of an Integer.

Review your practice with PhantomCodeAI

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