Answers for "kiem tra so hoan hao nhanh nhat"

C++
0

kiem tra so hoan hao nhanh nhat

bool KTSHT(long long int n)
{
	long long int sum = 1;
	if(n == 1 || n == 0 || n == 2 || n == 3 || n == 4 || n == 5)
		return false;
	for(long long int i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			if(i*i != n)
				sum += i + n/i;
			else
				sum += i;
		}
	}
	if(sum == n && n != 1)
		return true;
	return false;
}
Posted by: Guest on June-24-2021

Browse Popular Code Answers by Language