Link to home
Start Free TrialLog in
Avatar of jander1
jander1

asked on

Write, using a functional programming approach, a function to calculate recursively (using the + operation) any entry in the nine times table.

Write, using a functional programming approach, a function to calculate recursively (using the
+ operation) any entry in the nine times table.
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

This looks like a homework question so we cannot give direct answers. Where are you stuck? Recursion is basically just writing a fuction that does a small part of the problem and then calls itself to complete the problem.
The other important part is the stop condition (so the function knows when to stop calling itself). Here is a simple example

int factorial(int n)
{
  if( n == 0)
    return 1;
  else
    return n*factorial(n-1)
}
You are being asked to write a similar function for the 9 row in the multiplication table so if the function is passed any number, it returns 9 times that number using a function like the one above.

Let me know if you need any more help.
Avatar of jander1
jander1

ASKER

hi thanks for your responce!

it's not a homework question its just the way i worded it basicly i need a fuctional Recursion for the 9 times table? if you think its homework then can u give me one for like the 8 or 10 times table?

thanks.
Avatar of jander1

ASKER

Hi TommySzalapski,

Thank for your reply. can you confirm what the exact function is? this isn't homework

thanks.
Avatar of jander1

ASKER

will


int factorial(int n)
{
  if( n == 0)
    return 1;
  else
    return n*factorial(n-1)
}

work as the 9 times table?

thanks
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial