Is Perfect Number

This algorithm checks whether a given number is perfect number or not. Perfect number is a number which is equal to sum of its divisor. For example divisors of 6 are 1,2 and 3. The sum of these divisors is 6. So 6 is called as perfect number.



									Public Shared Function IsPerfectNumber(number As Integer) As Boolean
	Dim sum As Integer = 0
	Dim i As Integer = 1

	While i < number
		If number Mod i = 0 Then
			sum += i
		End If

		i += 1
	End While

	Return sum = number
End Function
								


Example

									Dim _isPerfectNumber = IsPerfectNumber(28)
								


Output

									true