Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
recursion
#7
(Apr-01-2019, 07:21 PM)mcgrim Wrote: this is what I came up with but not sure if is right.
For x sub (n)= x sub (n-1) + 10
would it perhaps be
def f(x):
    return x(i-1) + 10 
?
You need an if statement to make the computer decide when to stop recusing. Where does the value of i come from? Should i be another argument in your recursive function?

(Apr-01-2019, 11:42 PM)BillMcEnaney Wrote:
(Apr-01-2019, 07:21 PM)mcgrim Wrote: this is what I came up with but not sure if is right.
For x sub (n)= x sub (n-1) + 10
would it perhaps be
def f(x):
    return x(i-1) + 10 
?
You need an if statement to make the computer decide when to stop recusing. Where does the value of i come from? Should i be another argument in your recursive function?
I meant to type "recursing."
Reply


Messages In This Thread
recursion - by mcgrim - Apr-01-2019, 06:43 PM
RE: recursion - by ichabod801 - Apr-01-2019, 06:51 PM
RE: recursion - by mcgrim - Apr-01-2019, 06:58 PM
RE: recursion - by ichabod801 - Apr-01-2019, 07:06 PM
RE: recursion - by mcgrim - Apr-01-2019, 07:21 PM
RE: recursion - by BillMcEnaney - Apr-01-2019, 11:42 PM
RE: recursion - by ichabod801 - Apr-01-2019, 07:34 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020