I have a function
let simpleSum n =
let s = n * (n+1)/2
printf "%A " s
let result = simpleSum 10
I now want to make it recursive; tail-recursion without added variables is preferred.
There is something wrong with my statement: if n <= 0 then 0
let rec recSum n =
if n <= 0 then
0
else
recSum n*(n+1)/2
recSum 4
I run into the error:
FS0020: The result of this expression is implicitly ignored.
Consider using 'ignore' to discard this value explicitly, e.g. 'expr :> ignore',
or 'let' to bind the result to a name, e.g. 'let result = expr'.
How do I fix this? I want to avoid variables.