Numbers With Equal Remainder and Quotient
InterviewTime limit2sMemory limit256 MB
Given N, find the sum of all positive integers x whose quotient and remainder are equal when divided by N.
- Level
Easy2 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
A positive integer N is given. Call a positive integer x valid if, when x is divided by N, its quotient and remainder are equal.
Find the sum of all valid positive integers x.
Input
The first line contains a positive integer N not greater than 2,000,000.
Output
Output the sum of all valid positive integers.