0
Does anyone know how to print the first 3 odd perfect numbers in C?
5 ответов
+ 2
Make a program that finds the first 3 perfect numbers even and the first 3 odd perfect numbers. A perfect number is a positive integer, which is equal to the sum of all positive integers (excluding itself) that are divisors of the number. The first perfect number is 6, since its divisors are 1, 2, 3 and 1 + 2 + 3 = 6.
I could already do the one of the pairs but the one of the odd ones could not eh
+ 2
kevin josuè mondragon nuñez First make a function that accepts an integer and return whether or not its a perfect number. Then inside main write a loop that keeps incrementing a number, checking if its a perfect number using that function, and if it is check if its even or odd using n%2
+ 1
You already posted this question. A good addition to it would be to explain what perfect numbers are.
+ 1
if the smallest divisor you check for evens (not including 1) is 2, then you can check: 3, 5, ect for odd numbers.
+ 1
p=5
perfect=2**(p-1)*((2**p) -1)
where, p is the prime number.
⏺️The kth perfect number has k digits.
⏺️All the perfect numbers are even. It is still unknown whether odd perfect numbers exist or not.
source : https://www.cuemath.com/numbers/perfect-numbers/