Prime Number Check
Easy
+2 pts
Algorithms
4/4
🎯 In Python, you might write a prime check like this:
def is_perfect_square(n): if n < 0: return False root = int(n**0.5) return root * root == n
Checking primality in Rust follows similar logic to what you'd write in Python, but introduces a few language features worth understanding.
Early return
So far you've seen Rust functions where the last expression is the return value. But sometimes you want to bail out early — that's what …
Login to see the full exercise.
Topics