def kiem_tra_so_hoan_chinh(so):
if so <= 1:
return False
else:
tong = 0
for i in range(1, so):
if so % i == 0:
tong += i
if tong == so:
return True
else:
return False
np.random.seed(5)
arr1 = np.random.randint(low = 1, high = 101, size = 16)
arr1=arr1.reshape(4,4)
arr1
How can I use the function into array and print out arr1 line if it contains perfect number
If I use kiem_tra_so_hoan_chinh(arr1), it shows an error:
"ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"