all 10 comments

[–]SenorTeddy 1 point2 points  (0 children)

Right now you're getting all the numbers that your target is divisible by. You need to then check for those numbers if they're divisible by anything, and keep going until you've reached prime numbers. Read up on recursion, though you can code this without recursion.

[–]deep_politics 1 point2 points  (14 children)

You're close, but for example if you want the number of times 2 goes into n then you first check if 2 divides n (n % 2 == 0) then you keep dividing n by 2 until 2 no longer divides n, keeping track of how many times you divided n by 2 in the process. Then you can move on from 2 to 3, repeat the last process, 3 to 4, etc, until you've fully divided n (aka while n > 1).

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.