Python Forum
recursive procedure(total beginner)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
recursive procedure(total beginner)
#6
(Dec-13-2017, 12:59 PM)boris602 Wrote: The length is defined how long this procedure "x_(k+1)=p(x_k)-x_k" runs until i reach 0. So for example for x_0=7 , x_1 is =1 and x_2 is =0. So the length must be 2, but i dont know how i can code this and some numbers like x_0=6 always stay 6 and have to be breaked.

I think I understand now, you're generating a sequence Xk, Xk+1, Xk+2, ... where Xy = p(Xy-1) - Xy-1.

Generating the sequence is recursive and you stop when Xy = 0. So how many times do you calculate p(Xy-1) - Xy-1 before it returns zero and how do you stop when p(x) - x = x.

So the divisorGenerator method (which is a generator) can remember information it's calculated from previous calls. You're using that by storing things in large_divisors. Can you use it (the fact that generators remember information between calls) to keep track of things it has seen? Right now, you're just summing the list generated by divisorGenerator. Maybe you have to look at the list returned by divisorGenerator and add logic based on what it's returning.
Reply


Messages In This Thread
recursive procedure(total beginner) - by boris602 - Dec-12-2017, 02:29 PM
RE: recursive procedure(total beginner) - by mpd - Dec-12-2017, 03:29 PM
RE: recursive procedure(total beginner) - by mpd - Dec-13-2017, 12:46 PM
RE: recursive procedure(total beginner) - by mpd - Dec-13-2017, 01:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating Disassembler for a bin file(total beginner) SoulsKeeper 1 2,588 Sep-04-2018, 04:15 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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