Suma els n primers nombres


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C#, Go, Java

Escriu un algorisme recursiu per a sumar els n primers nombres.

Exemple:

n=10 -> 1+2+3+4+5+6+7+8+9+10=55

Input Format

Un nombre enter

Constraints

No hi ha

Output Format

La suma

Test Case 1

Input
1
Output
1

Test Case 2

Input
3
Output
6

Test Case 3

Input
5
Output
15

Test Case 4

Input
10
Output
55

Test Case 5

Input
20
Output
210

Test Case 6

Input
1000
Output
500500

Authorship: Gerard Falcó

CC BY-NC-SA 4.0