7 kyu
Sums of consecutive integers
1,120 of 1,798andrewferk
Description:
The sum of x
consecutive integers is y
. What is the consecutive integer at position n
? Given x
, y
, and n
, solve for the integer. Assume the starting position is 0.
For example, if the sum of 4 consecutive integers is 14, what is the consecutive integer at position 3?
We find that the consecutive integers are [2, 3, 4, 5]
, so the integer at position 3 is 5
.
position(4, 14, 3) == 5
Assume there will always be a sum of x
consecutive integers that totals to y
and n
will never be indexed out of bounds.
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Jul 26, 2015 |
Published | Jul 26, 2015 |
Warriors Trained | 5172 |
Total Skips | 537 |
Total Code Submissions | 6409 |
Total Times Completed | 1798 |
JavaScript Completions | 1120 |
C# Completions | 335 |
Python Completions | 398 |
Total Stars | 73 |
% of votes with a positive feedback rating | 91% of 293 |
Total "Very Satisfied" Votes | 251 |
Total "Somewhat Satisfied" Votes | 33 |
Total "Not Satisfied" Votes | 9 |