7 kyu

Sum of a sequence

17,291 of 50,831fyvfyv

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 Trained79862
Total Skips10597
Total Code Submissions135737
Total Times Completed50831
JavaScript Completions17291
PHP Completions2036
Haskell Completions633
Python Completions17308
Ruby Completions1330
Crystal Completions40
CoffeeScript Completions28
C# Completions2587
C++ Completions6106
C Completions1771
NASM Completions75
COBOL Completions20
Nim Completions35
Factor Completions19
D Completions18
Go Completions905
Rust Completions531
Scala Completions95
Java Completions1457
Lua Completions42
Prolog Completions7
Julia Completions12
Total Stars564
% of votes with a positive feedback rating88% of 4530
Total "Very Satisfied" Votes3584
Total "Somewhat Satisfied" Votes820
Total "Not Satisfied" Votes126
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