Haskell, 13 bytes
This is the shortest (I (削除) think (削除ここまで)thought):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree direct, 15 bytes
(*)=<<(/2).(+1)
Thanks @nimi for the idea!
Pointfree via sum, 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Haskell, 13 bytes
This is the shortest (I (削除) think (削除ここまで)thought):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Haskell, 13 bytes
This is the shortest (I (削除) think (削除ここまで)thought):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree direct, 15 bytes
(*)=<<(/2).(+1)
Thanks @nimi for the idea!
Pointfree via sum, 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Haskell, 13 bytes
This is the shortest (I think(削除) think (削除ここまで)thought):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Haskell, 13 bytes
This is the shortest (I think):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Haskell, 13 bytes
This is the shortest (I (削除) think (削除ここまで)thought):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Haskell, 13 bytes
This is the shortest (I think):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Standard foldRecursively, 19(削除) 22 (削除ここまで) 18 bytes
f n=foldr0=0;f n=n+f(+n-1)0[1..n]
Try it online! Thanks @maple_shaft for the idea & @Laikoni for golfing it!
RecursivelyStandard fold, 2219 bytes
f n|n<1=0|1<2=n+fn=foldr(n-1+)0[1..n]
Thanks @maple_shaft for the idea!
Haskell, 13 bytes
This is the shortest (I think):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Standard fold, 19 bytes
f n=foldr(+)0[1..n]
Recursively, 22 bytes
f n|n<1=0|1<2=n+f(n-1)
Thanks @maple_shaft for the idea!
Haskell, 13 bytes
This is the shortest (I think):
f n=sum[1..n]
Direct, (削除) 17 (削除ここまで) 13 bytes
f n=n*(n+1)/2
Thanks @WheatWizard for -4 bytes!
Pointfree 16 bytes
sum.enumFromTo 1
Recursively, (削除) 22 (削除ここまで) 18 bytes
f 0=0;f n=n+f(n-1)
Thanks @maple_shaft for the idea & @Laikoni for golfing it!
Standard fold, 19 bytes
f n=foldr(+)0[1..n]