Hi. I am currently having a prob. I need to create a function that takes in the number(n) as argument and returns true if n is a perfect number. I am not allowed to use vectors and for loop for this question. I am stuck at this few codes:
function num = perfect(n)i=1; sum = 0;while i <= n/2 if rem(n,i) == 0 else i = i +1 end sum = sum + i; end if n == sum n = true
I am a beginner in Matlab and I require assistance. Any kind soul out there to help me? Thanks!
Best Answer