Why is my program stuck in a recursive loo | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why is my program stuck in a recursive loo

I am trying to make a program where it would display the prime factors of a number but instead it is stuck in a never ending loop. https://code.sololearn.com/c0fcne5pIePB/?ref=app

18th Jul 2021, 6:38 AM
Purple Requiem
Purple Requiem - avatar
2 Answers
+ 8
The condition of your while loop is rem >= 1, despite the comment explicitly stating "rem" should be above 1. I think you meant rem > 1, as a remainder of exactly 1 would be indivisible to any prime factor. Furthermore, you forgot to increment 'f' after the if conditional, and repeatedly check the prime factor 2 instead of going on.
18th Jul 2021, 7:17 AM
Shadow
Shadow - avatar
0
Shadow OMFG THANK YOU SO MUCH!!!!
18th Jul 2021, 7:19 AM
Purple Requiem
Purple Requiem - avatar