Rewrite the following code written in Java to Python. public static boolean isPrime(int…
- User
Rewrite the following code written in Java to Python. public static boolean isPrime(int num) { // check if num is a multiple of 2 if (num % 2 == 0) { return false; } // if not, then just check the odds for(int i = 3; i * i <= num; i += 2){ if(num % i == 0){ return false; } } return true; }
Assistant
-
Original Java Logic Analysis:
- Checks if number is even → returns false
-