+ 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
11 Antworten
+ 18
*repost*
My prev version was without recursion: https://code.sololearn.com/WFvp472f88al/?ref=app
+ 12
https://code.sololearn.com/cCjD1K20IDAr/?ref=app
+ 11
Python:
def summation(n):
if n == 0:
return 0
return n + summation(n - 1)
print(summation(5))
#You are a great father!
+ 6
I am a beginner in JAVA. And this is my try
https://code.sololearn.com/cYJVy5hgwV44/?ref=app
+ 6
@Joker, tell your kid I said hello, guess s/he would make a great future for having a good dad *\^_^/*
+ 3
You've got a "little programmist" in your house ;)
https://code.sololearn.com/cT4otxPfopiK/?ref=app
+ 3
isn't it just
f of n = n^2-0.5n+0.5
or
f of n = n^2-0.5(n-1)
+ 2
Now it only he wasn't 6 and could have shown me HIS code to answer it lol
+ 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