+ 9

*Beginner Challenge*

My kid asked me what is 4+3+2+1.. I wrote him a recursive function to answer it and figured it was a good beginner project. Example- Input: 5 Output: 5 4 for a total of 9 3 for a total of 12 2 for a total of 14 1 for a total of 15 15

3rd Dec 2017, 5:27 PM
LordHill
LordHill - avatar
11 Respuestas
+ 18
*repost* My prev version was without recursion: https://code.sololearn.com/WFvp472f88al/?ref=app
3rd Dec 2017, 6:17 PM
Maz
Maz - avatar
+ 12
https://code.sololearn.com/cCjD1K20IDAr/?ref=app
4th Dec 2017, 12:00 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 11
Python: def summation(n): if n == 0: return 0 return n + summation(n - 1) print(summation(5)) #You are a great father!
3rd Dec 2017, 5:53 PM
Cool Codin
Cool Codin - avatar
+ 6
I am a beginner in JAVA. And this is my try https://code.sololearn.com/cYJVy5hgwV44/?ref=app
4th Dec 2017, 12:15 AM
More
More - avatar
+ 6
@Joker, tell your kid I said hello, guess s/he would make a great future for having a good dad *\^_^/*
4th Dec 2017, 5:36 AM
Ipang
+ 3
You've got a "little programmist" in your house ;) https://code.sololearn.com/cT4otxPfopiK/?ref=app
3rd Dec 2017, 8:23 PM
Cuttek
Cuttek - avatar
+ 3
isn't it just f of n = n^2-0.5n+0.5 or f of n = n^2-0.5(n-1)
4th May 2018, 8:55 PM
Ask Plays
Ask Plays - avatar
+ 2
Now it only he wasn't 6 and could have shown me HIS code to answer it lol
3rd Dec 2017, 6:05 PM
LordHill
LordHill - avatar
+ 1
https://code.sololearn.com/cIWc4NA34Sga/?ref=app https://code.sololearn.com/cFoNWY7GXL8H/?ref=app https://code.sololearn.com/cjSNCrLFHp9t/?ref=app My factorial functions :) Take a look
7th Dec 2017, 12:23 AM
Jonathan Álex
Jonathan Álex - avatar