• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

dumb question

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone explain to me how to solve a function for a given value, for example:

for value of func1(8,3)?

For the record, I changed the values so you won't be just doing my hopmework for me.

Thank you
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Doug Cates:
Can anyone explain to me how to solve a function for a given value,...



I left a few things out, but this is called a recursive function - and will be a standard introductory demo program.

What are you trying to accomplish ?
 
Doug Cates
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The assignment is to solve the function for given variables. I don't really understand exactly how to plug them back in and arrive at a numerical answer.
Thanks
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How much experience coding do you have ? You answered my question, in the manner that tells me how to go about responding - but you need to tell me if you are past the get-going of coding a sample program, compiling it and then running it.

There are later ways of doing this, but what I always do is just place a main() in the class and then run it as a program. To get data out, I usually write to a file to avoid some other issues, but one can put up a Graphical User Interface - which gets distracting if you have not written five or ten programs effectively. It helps if you tell me what editor you are using. This may be an IDE - Integrated Development Environment, which ususually have editors built in. Sometimes they will run the program you have compiled, but that can become a complexity in it's self.
[ June 18, 2007: Message edited by: Nicholas Jordan ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doug --

I think you're asking how to work out the answer on paper, right? I can't offer you any especially handsome or formal way to do it; perhaps someone else would. But basically you can just think like a computer and walk through the code, a line at a time, writing down intermediate results. For example, for this function, you want to know func1(8, 3). So you'd ask "is either argument 1?" And the answer is no, so now you want func1(7, 2) + 3*func1(7,3). So you'd look at func1(7, 2) first, and ask if the arguments are 1. Nope, so now you want func1(6, 1) + 2*func1(6, 2) + 3*func1(7, 3). Again, take the first one. This time, one of the arguments [b]is[/i] 1, so you immediately substitute "1", and now you're looking for 1 + 2*func1(6, 2) + 3*func1(7, 3). After a few more steps, the middle term will be broken down, and then you'd go after the last one.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahhh,....yes.

And when you get ready to use the computer to run the steps Ernest Friedman-Hill describes, remember that computers are really good at doing thousands of computations a second.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic