Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Aaah, the beauty, the elegance...

Manku Thimma
Ranch Hand
Posts: 108
... of a recursive solution!
Solve for a<sub>1</sub> to a<sub>n</sub>, given b<sub>1</sub> to b<sub>n</sub>, and c<sub>1</sub> to c<sub>n</sub>:
a<sub>n</sub>b<sub>1</sub> = c<sub>1</sub>
a<sub>n-1</sub>b<sub>1</sub> + a<sub>n</sub>b<sub>2</sub> = c<sub>2</sub>
a<sub>n-2</sub>b<sub>1</sub> + a<sub>n-1</sub>b<sub>2</sub> + a<sub>n</sub>b<sub>3</sub> = c<sub>3</sub>
:
:
a<sub>1</sub>b<sub>1</sub> + a<sub>2</sub>b<sub>2</sub> + a<sub>3</sub>b<sub>3</sub> + ... + a<sub>n</sub>b<sub>n</sub> = c<sub>n</sub>

[This message has been edited by Manku Thimma (edited July 21, 2001).]

Paul Ralph
Ranch Hand
Posts: 314
As it is...
3 variables, 1 equation then...
5 variables, 2 equations
7 variables, 3 equations...and so forth.
Don't we need to know how the b variables relate to each other or how the b variables relate to the c variables?
Or something like that?
Paul R

Andy Ceponis
Ranch Hand
Posts: 782
8

Andy Ceponis
Ranch Hand
Posts: 782
or was it -4958390.328947234121?

Jim Yingst
Wanderer
Sheriff
Posts: 18671
I believe the canonical answer to this is:
42

Manku Thimma
Ranch Hand
Posts: 108
Where are all these numbers popping up from?
You are given three arrays a, b, and c, with n elements each. Using the above set of equations, write a recursive function to fill in the elements 1 to n of array a, given the values in elements 1 to n in arrays b and c.
So, using the equations, a<sub>n</sub> = c<sub>1</sub>/b<sub>1</sub>. And now, using a<sub>n</sub>, we get a<sub>n-1</sub> = (c<sub>2</sub> - a<sub>n</sub>b<sub>2</sub>) / b<sub>1</sub>. And so on... to get a<sub>1</sub>. Enjoy!

[This message has been edited by Manku Thimma (edited July 23, 2001).]

Anonymous
Ranch Hand
Posts: 18944
Do you guys have life? For god's sakes, why are you posting recursive functions on the net? Go out and do something social for crying out loud.

Greg Harris
Ranch Hand
Posts: 1012
what are you doing here? why are you worried about our tension breakers? do you not have anything better to do?
sorry, i just needed to vent my frustration.

Jim Yingst
Wanderer
Sheriff
Posts: 18671
> Do you guys have life?
Sorry Ronnie - not everyone has such sophisticated forms of entertainment as you enjoy.

Greg Harris
Ranch Hand
Posts: 1012
busted!
did you notice that your ip is showing "onlooker"... i think jim just exposed you.

Ronnie Johnson
Ranch Hand
Posts: 106
Woah, guys, chill out, I did not post this, some girl named Neha at a camp i was just at saw me on the forum, and posted it, not I I happen to like mathematical puzzels, as for the Greg, you just look like a moron now, "Oh no!, They exposed me now!" I bet if you look at my IP now, you can find some more cool stuff on me, say for instance IT IS NOT THE SAME ONE. Greg, get a brain.

[This message has been edited by Ronnie Johnson (edited July 31, 2001).]

Greg Harris
Ranch Hand
Posts: 1012
sorry, ronnie, i guess i need to go see the wizard and ask to have my brain back... follow the yellow brick road, follow the yellow brick road, follow, follow, follow, follow, follow the yellow brick road... we're off to see the wizard, the wonderful wizard of oz!
(sorry, i removed the pic of the scarecrow)...
[This message has been edited by Greg Harris (edited August 14, 2001).]

Ronnie Johnson
Ranch Hand
Posts: 106
hehe