7 kyu

Sum of a sequence

17,369 of 51,186fyvfyv

Description:

Your task is to write a function which returns the sum of a sequence of integers.

The sequence is defined by 3 non-negative values: begin, end, step.

If begin value is greater than the end, your function should return 0. If end is not the result of an integer number of steps, then don't add it to the sum. See the 4th example below.

Examples

2,2,2 --> 2
2,6,2 --> 12 (2 + 4 + 6)
1,5,1 --> 15 (1 + 2 + 3 + 4 + 5)
1,5,3  --> 5 (1 + 4)

This is the first kata in the series:

  1. Sum of a sequence (this kata)
  2. Sum of a Sequence [Hard-Core Version]
Fundamentals
Algorithms
Mathematics

More By Author:

Check out these other kata created by fyvfyv

Stats:

CreatedJan 6, 2017
PublishedJan 6, 2017
Warriors Trained80296
Total Skips10653
Total Code Submissions136386
Total Times Completed51186
JavaScript Completions17369
PHP Completions2043
Haskell Completions635
Python Completions17444
Ruby Completions1338
Crystal Completions41
CoffeeScript Completions28
C# Completions2597
C++ Completions6171
C Completions1776
NASM Completions75
COBOL Completions20
Nim Completions35
Factor Completions19
D Completions18
Go Completions921
Rust Completions540
Scala Completions95
Java Completions1485
Lua Completions46
Prolog Completions8
Julia Completions12
Total Stars570
% of votes with a positive feedback rating88% of 4550
Total "Very Satisfied" Votes3600
Total "Somewhat Satisfied" Votes823
Total "Not Satisfied" Votes127
Total Rank Assessments15
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • fyvfyv Avatar
  • Javatlacati Avatar
  • GiacomoSorbi Avatar
  • donaldsebleung Avatar
  • Chrono79 Avatar
  • Dentzil Avatar
  • EatYourBeetS Avatar
  • Papaltine Avatar
  • Voile Avatar
  • Madjosz Avatar
  • metagn Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • hobovsky Avatar
  • uniapi Avatar
  • stellartux Avatar
  • user8436785 Avatar
  • ejini战神 Avatar
  • Reargem Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • razetime Avatar
  • Thomas-Teo Avatar
  • KayleighWasTaken Avatar
  • metatable Avatar
Ad