Avatar ·

The use of recursion is more than 1000 times

📁 example, AI, Beginner, project

I am a beginner in programming in Python (my 1st programming language). I solved problem No. 12 from the Euler project. I used recursion in functions, but unfortunately, to solve the problem, I will have to use recursion more than 1000 times. I would like to know how to solve this problem without using recursion in order to know about it for the future.

How to improve the code and what do you think about my variable and function names?

This is how the problem is formed: the sequence of triangular numbers is generated by adding natural numbers. For example, the 7th triangular number is 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten triangular numbers:

1, 6, 10, 15, 21, 28, 36, 45, 55, ...

We list the divisors of the first seven triangular numbers: