answersLogoWhite

0


Best Answer

int sum (int from, int to, int step)
{
if (from>to) return 0;
else return from + sum (from+step, to, step);

}

...

n = sum (2, 150, 2);

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a recursive function to find sum of even numbers from 2 to 150?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

How would you explain to a seventh grader the difference between the domains of an odd root radical function and an even root radical function?

To start with, when you multiply an even number of negative numbers, the answer is positive. When you multiply an odd number of negative numbers, the answer is negative. When you multiply any number of positive numbers, the answer is always positive. For positive numbers, the value of a power is always positive. For negative numbers, the value of an odd power is negative, and the value of an even power is positive. Finding roots is the inverse of taking powers, so that an odd-root function can be evaluated for any value of x. An even-root function, however, cannot be evaluated when the value of x is negative, since an even power can never result in a negative answer. The domain of an odd root function is all real numbers; the domain of an even root function is the non-negative real numbers.


How do you write an odd number with even numbers?

If you add, subtract, or multiply two even numbers, you will get an even number. If you divide an even number by another even number, you may get an even number, an odd number, or even a fraction.


How can you use each of the digits 23468 once to write the largest possible even numbers?

86432


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


What are multiples of 2 called?

Those are called "even numbers".Those are called "even numbers".Those are called "even numbers".Those are called "even numbers".

Related questions

Write a recursive function to find sum of even numbers from 2 to 50 using C?

I can't imagine a useful reason to have a recursive function to find this, but here you go: int sumEvens(int start, int end) { // end condition if (start > end) { return 0; } // correction if we start on an odd number if (start % 2 == 1) { return sumEvens(start + 1, end); } // actual work return start + sumEvens(start + 2, end); } Invoke with sumEvens(2, 50) to get the sum of all even numbers in the range [2,50]


What happens if recursion function is declared inline?

An inline function replaces the call to the function by the body of the function, thus reducing the overhead of saving the context in stack. This is good for functions which are small in size and called occasionally. A recursive function calls an instance of itself and thus can be a deeply nested. Different compilers handle this differently. Some will inline it up to a certain depth and then call a non-inlined instance for further recursion; others will not inline the function at all and generate a normal function call.


Write an algorithm to print sum of all even numbers?

Start print "the sum of all even numbers is infinite" end


What are the even numbers below 100?

The get a list of all even numbers, write the number 2, then slip the next number (3) and write the number 4. Continue by skipping every other number, which will be the odd numbers. Alternatively, write a consecutive list of all of the numbers from 1 to 50, then multiply each one by 2. The products are all of the multiples of 2, which are even numbers.


How would you explain to a seventh grader the difference between the domains of an odd root radical function and an even root radical function?

To start with, when you multiply an even number of negative numbers, the answer is positive. When you multiply an odd number of negative numbers, the answer is negative. When you multiply any number of positive numbers, the answer is always positive. For positive numbers, the value of a power is always positive. For negative numbers, the value of an odd power is negative, and the value of an even power is positive. Finding roots is the inverse of taking powers, so that an odd-root function can be evaluated for any value of x. An even-root function, however, cannot be evaluated when the value of x is negative, since an even power can never result in a negative answer. The domain of an odd root function is all real numbers; the domain of an even root function is the non-negative real numbers.


How do you write an odd number with even numbers?

If you add, subtract, or multiply two even numbers, you will get an even number. If you divide an even number by another even number, you may get an even number, an odd number, or even a fraction.


Write algorithm and draw flowchart to find the sum of even numbers?

jgfujtf


What is the inverse of an even function?

An even function cannot have an inverse.If f(x) = y, then if f is an even function, f(-x) = y.Then, if g were the inverse function of f, g(y) would be x as well as -x.But a one-to-many relationship is not a function.


What are demerits of recursion?

Demerits of recursion are: Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods. Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space. The recursive programs take considerably more storage and take more time during processing.


What numbers as a sum of two prime numbers 95?

You can't write that as the sum of two prime numbers. Note: Goldbach's Conjecture (for expressing numbers as the sum of two prime numbers) applies to EVEN numbers.


How can you use each of the digits 23468 once to write the largest possible even numbers?

86432


What is the sum of the even numbers between 1and 11?

write an algo to find the sum of even number from 1to n