answersLogoWhite

0


Best Answer

int sum (int n)

{

if (n<=1) return n;

else return n*n + sum (n-1);

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Recursive functions for the sum of squares?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a C program to calculate the sum of squares of numbers from 1 to N?

#include &lt;iostream&gt; using namespace std; int main() { int i,sum; // variables sum = 0; // initialize sum /* recursive addition of squares */ for (i = 1; i &lt;= 30; i++) sum = sum + (i * i); cout &lt;&lt; sum &lt;&lt;" is the sum of the first 30 squares." &lt;&lt; endl; return 0; }


Are there any functions whose sum of squares equals 1?

cos2x + sin2x = 1; cosh2x + sinh2x = 1.


The sum of two positive numbers is 4 and the sum fo their cubes is 28 What is the sum of their squares?

The sum of their squares is 10.


If the regression sum of squares is large relative to the error sum of squares is the regression equation useful for making predictions?

If the regression sum of squares is the explained sum of squares. That is, the sum of squares generated by the regression line. Then you would want the regression sum of squares to be as big as possible since, then the regression line would explain the dispersion of the data well. Alternatively, use the R^2 ratio, which is the ratio of the explained sum of squares to the total sum of squares. (which ranges from 0 to 1) and hence a large number (0.9) would be preferred to (0.2).


Does javascript support recursive functions?

Yes, but a recursive function running for a long time would eventually cause your program to crash.


Why is the residual sum of squares bigger then total sum of squares when there isn't a constant?

There is a calculation error.


Write a c program to find GCD of two given integers by using both recursive n non recursive functions?

i love u darling


What has the author J C E Dekker written?

J. C. E. Dekker has written: 'Recursive equivalence types' -- subject(s): Recursive functions


The efficiency of using recursive function rather than using ordinary function?

For some algorithms recursive functions are faster, and there are some problems that can only be solved through recursive means as iterative approaches are computationally infeasible.


Explain the square of the sum of two numbers is different from the sum of the squares of two numbers?

split 10 in two parts such that sum of their squares is 52. answer in full formula


Can 8081 be the sum of two perfect squares?

8081 can be the sum of two perfect squares because its perfect squares are 41 x41+80x80=1681+6400. Answer=1681+6400


Two numbers have a sum of 20 if their squares is a minimum find the numbers Complete the square to find the minimum?

Sum of squares? Product?