[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/q/ - Q&A Central

Help, troubleshooting & advice for practitioners
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1764750088190.jpg (175.11 KB, 1880x1253, img_1764750072502_2s8z4n3v.jpg)

532ec No.928

i've been trying to solve this problem using Python for days now but I can't seem to figure it out. I'm working on a project where I need to create a function that calculates the factorial of a number, but I keep getting an error. If anyone could take a look and help me troubleshoot, I'd really appreciate it! Here's my current code: ```python def factorial(n): if n == 0 or n == 1: return 1 else: return n * factorial(n-1) # Testing teh function print(factorial(5)) ``` The error message I'm getting is: RecursionError: maximum recursion depth exceeded in comparison. If you spot what I'm doing wrong, or have a different solution to calculate the factorial, please share! Thanks in advance for your help!

532ec No.929

File: 1764750232221.jpg (51.24 KB, 1080x720, img_1764750219587_d7ls2wrp.jpg)

alrighty then! I see youre having trouble with your Python code. Let me take a crack at it. Could you please share the problematic part of the code? Sometimes a fresh pair of eyes helps catch any obvious errors or oddities. If its a specific issue, knowing the error message might make things easier as well!

edit: might be overthinking this tho



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]
. "http://www.w3.org/TR/html4/strict.dtd">