7 kyu

Triangular Treasure

4,806 of 29,427JulianNicholls

Description:

Triangular numbers are so called because of the equilateral triangular shape that they occupy when laid out as dots. i.e.

1st (1)   2nd (3)    3rd (6)
*          **        ***
           *         **
                     *

You need to return the nth triangular number. You should return 0 for out of range values:

For example: (Input --> Output)

0 --> 0
2 --> 3
3 --> 6
-10 --> 0
Algorithms
Mathematics

More By Author:

Check out these other kata created by JulianNicholls

Stats:

CreatedOct 16, 2013
PublishedOct 16, 2013
Warriors Trained54180
Total Skips6725
Total Code Submissions104510
Total Times Completed29427
Ruby Completions2610
JavaScript Completions9806
CoffeeScript Completions475
Haskell Completions629
C# Completions2524
Java Completions5270
Python Completions4806
Dart Completions1205
Swift Completions1683
C Completions642
Clojure Completions67
COBOL Completions13
Factor Completions16
Julia Completions32
Rust Completions234
NASM Completions62
SQL Completions1040
TypeScript Completions126
Scala Completions22
C++ Completions39
Total Stars290
% of votes with a positive feedback rating84% of 2630
Total "Very Satisfied" Votes1962
Total "Somewhat Satisfied" Votes520
Total "Not Satisfied" Votes148
Ad
Contributors
  • JulianNicholls Avatar
  • jhoffner Avatar
  • SagePtr Avatar
  • bkaes Avatar
  • GiacomoSorbi Avatar
  • TehCupcakes Avatar
  • kiwaa Avatar
  • lessonteacher Avatar
  • JohnTheBastard Avatar
  • kazk Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • Madjosz Avatar
  • rowcased Avatar
  • rsa Avatar
  • monadius Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • mauro-1 Avatar
  • Kacarott Avatar
  • dfhwze Avatar
  • Mednoob Avatar
  • KayleighWasTaken Avatar
  • SummerTheCoder Avatar
Ad