Return to site

Test Your Python Skills

make a factorial function in 3 lines of code

January 23, 2020

I am assuming that you know factorials already. If this is a new term or you forgot what it means, you may find details at amazing wikipedia. Your goal is to edit only 3 lines in the following Python code to make factorial function working for 0 to 10. We don't like large numbers because it throws us "out of memory".

Well, you may not trust me. Most likely would like to test the program with a large number to do a factorial.

NO PROBLEM

You may need to make factorial function work first before you could do its memory test. Good Luck!

I almost forgot to tell you that this program rotated our logo by 90 degrees. We are not happy about it. If you get bored while writing 3 lines of code, you can click on the logo and use arrow keys on your keyboard to fix it. The team at Competitive Kids STEM will appreciate your help to fix logo alignment. There is a "Check" button next to the "Run" button for you to validate if your code can handle factorials.

Finally, a famous guy wrote a long email and said I am sorry, I didn't have time to write a shorter email, hence I am writing a longer one. Well, writing efficient code is hard. Never judge a programmer by the number of lines of code s/he writes. On an unrelated topic, what is factorial of zero? Is it one? Factorial of zero is one. That's very strange. One more mystery for you to solve. I have full faith in you to solve all of this mess.

NOW YOU CAN HAVE FUN.

BTW, please don't post answers in the comment section. We would like other people to solve it themselves. You can provide hints or ask questions.