Explore Westonci.ca, the premier Q&A site that helps you find precise answers to your questions, no matter the topic. Connect with a community of experts ready to provide precise solutions to your questions on our user-friendly Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

Give a recursive algorithm for finding the sum of the
first n odd positive integers.


Sagot :

I'm writing that in some sort of pseudocode; if you don't understand it, feel free to ask for more details in the comments.

function sumOdd(n)
    if n==1 then
        return 1
    end if
    return (sumOdd(n-1))+(n*2-1)
end function