Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
recursive action
#1
i dont understand how this code works, as per my understanding every time the def function will be called , why it returns a result.

def rabbits(n):
    if n<1:
        return 0
    else:
        if n==0 or n==1:
            return 1
        else:
            return rabbits(n-1)+rabbits(n-2)-rabbits(n-5)
Reply


Messages In This Thread
recursive action - by elhetch - Jun-06-2017, 01:01 PM
RE: recursive action - by micseydel - Jun-06-2017, 03:46 PM
RE: recursive action - by volcano63 - Jun-06-2017, 03:58 PM
RE: recursive action - by snippsat - Jun-06-2017, 04:03 PM
RE: recursive action - by micseydel - Jun-06-2017, 04:04 PM
RE: recursive action - by snippsat - Jun-06-2017, 04:14 PM
RE: recursive action - by micseydel - Jun-06-2017, 04:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pixel color and action Sartre 4 2,155 Apr-13-2023, 03:26 AM
Last Post: Sartre
Question Running an action only between certain times alexbca 9 1,793 Mar-15-2023, 04:21 PM
Last Post: deanhystad
  Checkbox itens with a button to run action Woogmoog 3 973 Dec-19-2022, 11:54 AM
Last Post: Woogmoog
Question Running an action only if time condition is met alexbca 5 1,361 Oct-27-2022, 02:15 PM
Last Post: alexbca
  Combine Two Recursive Functions To Create One Recursive Selection Sort Function Jeremy7 12 7,503 Jan-17-2021, 03:02 AM
Last Post: Jeremy7
  Have an amount of time to perform and action CookieGamez2018 1 2,970 Dec-21-2018, 07:12 AM
Last Post: Gribouillis
  action on MQTT while long loop is running runboy 4 6,127 Oct-05-2018, 11:57 PM
Last Post: runboy
  Hourly action resetter with threading? alex36540 3 3,366 Jan-10-2018, 07:13 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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