What is the value of h(231,8) for the function below?
2.Consider the following function h.
The function h(n) given above returns True for a positive number n whenever:
n is a multiple of 2
n is a composite number
n is a prime number
n is a perfect square
[b]what would be the output of the following two programs in python?[/b]
1 2 3 4 5 |
def h(m,n): ans = 0 while (m > = n): (ans,m) = (ans + 1 ,m - n) return (ans) |
1 2 3 4 5 6 |
def h(n): f = 0 for i in range ( 1 ,n + 1 ): if n % i = = 0 : f = f + 1 return (f % 2 = = 1 ) |
n is a multiple of 2
n is a composite number
n is a prime number
n is a perfect square
[b]what would be the output of the following two programs in python?[/b]