Write a function that checks whether a number is prime or not.

Depending on the student level I would accept a simple answer such as: (cannot format code) or expect a more complex answer with optimization such as sieve of Eratosthenes

AC

Related Python Mentoring answers

All answers ▸

How do I define a function in Python?


What built-in types does python provide?


How might we implement the bubble sort algorithm in Python


Write a recursive function to return the nth Fibonacci number in Python