Python Forum
math problem using recursion?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
math problem using recursion?
#7
Ok, first, it is a decimal point. I was only using it to delineate between the factors for
visual clarity.

Next, I didn't know if this was a good problem for recursion. I was kinda hoping it was just
so I can get some experience with recursion. But if it doesn't need it that's ok too.

The list of primes is there because when factoring the only numbers needed to check for
divisibility are the primes up to the square root of the original number. And since Python
doesn't seem to have any prime routines I had to add the list. Normally when working with
primes I use UBasic but since I'm trying to learn Python...

True, I suppose I didn't really need the dictionary. I could just compute on the fly but this
way I could 'see' things better.

Yes, I believe I mentioned earlier that the seed number is a semi-prime. And a semi-prime
is indeed a number with only 2 factors (excluding 1 and the number itself).

I tried your code (adding a couple of lines for initial input) but got an error.

Error:
Traceback (most recent call last): File "c:\Python38-32\Scripts\P1015b.py", line 16, in <module> a = divisors(x) File "c:\Python38-32\Scripts\P1015b.py", line 10, in divisors new_numbers(div) NameError: name 'new_numbers' is not defined
I take it there's more to it than what you showed?
Reply


Messages In This Thread
math problem using recursion? - by mnh001 - Sep-01-2020, 03:54 PM
RE: math problem using recursion? - by DPaul - Sep-01-2020, 05:31 PM
RE: math problem using recursion? - by Larz60+ - Sep-01-2020, 06:52 PM
RE: math problem using recursion? - by mnh001 - Sep-01-2020, 08:17 PM
RE: math problem using recursion? - by mnh001 - Sep-01-2020, 10:57 PM
RE: math problem using recursion? - by DPaul - Sep-02-2020, 09:49 AM
RE: math problem using recursion? - by mnh001 - Sep-02-2020, 02:35 PM
RE: math problem using recursion? - by DPaul - Sep-02-2020, 05:22 PM
RE: math problem using recursion? - by bowlofred - Sep-02-2020, 05:36 PM
RE: math problem using recursion? - by mnh001 - Sep-02-2020, 06:24 PM
RE: math problem using recursion? - by Gribouillis - Sep-02-2020, 07:14 PM
RE: math problem using recursion? - by SmartGrid - Sep-03-2020, 12:55 PM
RE: math problem using recursion? - by mnh001 - Sep-03-2020, 02:34 PM
RE: math problem using recursion? - by DPaul - Sep-03-2020, 02:52 PM
RE: math problem using recursion? - by mnh001 - Sep-03-2020, 07:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Math Problem cryxma 2 1,971 Dec-21-2020, 09:53 PM
Last Post: Gribouillis
  GCF function w recursion and helper function(how do i fix this Recursion Error) hhydration 3 2,599 Oct-05-2020, 07:47 PM
Last Post: deanhystad
  Math problem in Python - pyqt5 rwahdan 6 5,835 Jun-18-2019, 08:11 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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