Your printing out statement in sum can never be reached (can you see why?). Java's compiler recognizes this and will through an error. Put that print out statement somewhere inside your main method,...
Type: Posts; User: helloworld922
Your printing out statement in sum can never be reached (can you see why?). Java's compiler recognizes this and will through an error. Put that print out statement somewhere inside your main method,...
Your algorithm needs a little work. Try this:
1. See if your current number n is 1. If it is, return 1.
2. Otherwise, sum(n) = sum(n-1) + n