473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Recursive funct that calculates the sum of first n odd numbers

10
Hello,

Does anyone have a recursive C++ program that calculates the sum of the first 50 (more or less) odd natural numbers?

Thank you,
Tukeind
Apr 20 '07 #1
5 6694
chella
51
Hello,

Does anyone have a recursive C++ program that calculates the sum of the first 50 (more or less) odd natural numbers?

Thank you,
Tukeind

Hi,
You try this program and if you have any problem, post it. People are ready to help you.

Regards,
Chella
Apr 20 '07 #2
JosAH
11,448 Expert 8TB
Also note that the sum of the first n odd numbers is a square number.

kind regards,

Jos
Apr 20 '07 #3
Tukeind
10
Hi Chella,

I was hoping that you would have a working copy that I could use?

Thank you,
Tukeind

Hi,
You try this program and if you have any problem, post it. People are ready to help you.

Regards,
Chella
Apr 20 '07 #4
JosAH
11,448 Expert 8TB
Hi Chella,

I was hoping that you would have a working copy that I could use?

Thank you,
Tukeind
Sorry, we don't give out boiler plate code; it's *your* homework/assignment, so
*you* try it first. When you get stuck, post your question here and we'll do our
best to help you out. You were given that assignment so that you'll learn from
it; you won't learn anything by copying/pasting source code created by others.

kind regards,

Jos
Apr 20 '07 #5
Tukeind
10
Thanks...it was worth a shot!...I better get it written for class today...

Sorry, we don't give out boiler plate code; it's *your* homework/assignment, so
*you* try it first. When you get stuck, post your question here and we'll do our
best to help you out. You were given that assignment so that you'll learn from
it; you won't learn anything by copying/pasting source code created by others.

kind regards,

Jos
Apr 20 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Steve Goldman | last post by:
Hi, I am trying to come up with a way to develop all n-length permutations of a given list of values. The short function below seems to work, but I can't help thinking there's a better way. ...
2
by: | last post by:
OK: Purpose: Using user's input and 3 recursive functions, construct an hour glass figure. Main can only have user input, loops and function calls. Recursive function 1 takes input and displays...
4
by: Rodusa | last post by:
I am having problem to apply updates into this function below. I tried using cursor for updates, etc. but no success. Sql server keeps telling me that I cannot execute insert or update from inside...
7
by: Jon Slaughter | last post by:
#pragma once #include <vector> class empty_class { }; template <int _I, int _J, class _element, class _property> class RDES_T {
4
by: Nicolas Vigier | last post by:
Hello, I have in my python script a function that look like this : def my_function(arg1, arg2, opt1=0, opt2=1, opt3=42): if type(arg1) is ListType: for a in arg1: my_function(a, arg2,...
64
by: dmattis | last post by:
I am trying to write a recursive version of Power(x,n) that works by breaking n down into halves(where half of n=n/2), squaring Power(x,n/2), and multiplying by x again if n was odd, and to find a...
41
by: Harry | last post by:
Hi all, 1)I need your help to solve a problem. I have a function whose prototype is int reclen(char *) This function has to find the length of the string passed to it.But the conditions...
1
by: abc12334 | last post by:
Im supposed to create a recursive and non recursive function to calculate this. F(n) = 1 for n = 0 or n = 1 or n=2 F(n) = F((n+1)/2)^2 + F((n-1)/2)^ 2 for n is odd F(n) = F(n/2 +...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.