- 2
Python
def h(n): f = 0 for i in range(1,n+1): if n%i == 0: f = f + 1 return(f == 2) The function h(n) given above returns True for a positive number n whenever: A) n is a multiple of 2 B) n is a composite number C) n is a prime number D) n has an even number
2 Answers
+ 18
C) n is prime
if n is prime the remainder will be =0 only for %1 & %n
so if condition will become true twice and thus the f will be incremented twice by 1 making it 2
and returning ans true
âïžđđ
- 3
Ty