Questions tagged [perfect-numbers]

A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself

A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself.

An example of a perfect number is 6, as 1, 2 and 3 are its divisors and 1+2+3 = 6

123 questions
0
votes
3 answers

Finding perfect numbers between 1 and 100

How can I generate all perfect numbers between 1 and 100? A perfect number is a positive integer that is equal to the sum of its proper divisors. For example, 6(=1+2+3) is a perfect number.
FRANK
  • 1
  • 1
  • 2
0
votes
1 answer

breaking out of a double after an elapsed time in C

I have a question I am writing a code that find the perfect number by brute forcing the algorithm which is required by my assignment. I want to see how far the ranges goes in 15 seconds. I tried using a while loop and an alarm but it seems to not…
jtd92
  • 359
  • 2
  • 6
  • 16
0
votes
3 answers

C++ Perfect Number With Nested Loops Issue

What I am trying to do is search for a perfect number. A perfect number is a number that is the sum of all its divisors, such as 6 = 1+2+3. Basically what I do here is ask for 2 numbers and find a perfect number between those two numbers. I have a…
n0de
  • 155
  • 4
  • 14
-1
votes
3 answers

I'm supposed to find all of the perfect numbers in between 2-20,000

As the title says, I'm supposed to write a program that outputs all the perfect numbers between 2-20,000. The program I have written looks correct to me, but it only outputs "6" even though it's in a for loop and it should be giving me the rest of…
-1
votes
1 answer

About perfect numbers

a = input('input a number :') for i in range(1,int(a)): b=0 for z in range(1,int(a)): if i == z : continue elif i%z == 0: print('i = ',i,'z =',z) b += z print('b = ',b) …
-1
votes
2 answers

A program that finds all four of the perfect numbers that are less than 10000

everyone. I have a question about an exercise from Brian Heinold's A Practical Introduction to Python Programming that reads "A number is called a perfect number if it is equal to the sum of all of its divisors, not including the number itself. For…
-1
votes
3 answers

why do we iterate to root(n) to check if n is a perfect number

while checking if a number n is perfect or not why do we check till square root of (n)? also can some body explain the if conditions in the following loop for(int i=2;i
-1
votes
1 answer

Reversing an array without using another array

I have been trying this using two arrays, and it was successful but the in-place reversing was bit confusing for me. if you can help, that will be great public class reverseOfAnArray { int[] reverseCal(int arr[]){ int i,j=0; for…
user14653215
-1
votes
1 answer

Reads an integer and print all perfect number smaller than given integer

I can find perfect numbers but I can't print all perfect numbers smaller than a given integer. int main() { cout << "Enter a number "; int number{}; cin >> number; int sum{}; int j{}; for (int i = 1; i < number ; i++) { …
-1
votes
2 answers

Why won't my python code display any output for my algorithm?

I am making an algorithm with python to find perfect numbers up to 100000000000000. I have created some code for this that should do it, and it does not throw up any errors, but the code just outputted nothing and is running continuously. I have…
AtomProgrammer
  • 245
  • 3
  • 13
-1
votes
8 answers

Perfect numbers 1 to n

Write an algorithm that prints perfect numbers from 1 to n. To determine if a number is perfect add up all the factors of the number that are less than the number. If the sum is equal to the number, it is perfect. import…
user605989
  • 15
  • 2
  • 3
  • 7
-1
votes
1 answer

How do I return the sum of two perfect numbers in C

I have a method named henry that takes two integer arguments, i and j, and returns the sum of the ith and jth perfect numbers. For example, henry(1, 3) should return 502 because 6 is the 1st perfect number and 496 is the 3rd perfect number and 6 +…
-1
votes
1 answer

project euler task 23

I don't get the part of the task: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a…
parsecer
  • 4,758
  • 13
  • 71
  • 140
-1
votes
2 answers

My Java program is only outputting two answers, the other two aren't shown

My program should spell the inputted word backwards, follow to the next line and answer if the word inputted is a Palindrome. Then it will take the accompanying number, output if it is prime or not then output if it is perfect or not. My output in…
Noivern Evo
  • 111
  • 3
  • 11
-1
votes
1 answer

Printing all perfect and non perfect numbers 6 to n

I'm trying to print all from 6 to n but when i run the code it gives me all the numbers but not the right perfect numbers. For example when I enter 30 it prints out all numbers but it says only 6 and 7 are perfect numbers only 7 is not a perfect…
user3247712
  • 37
  • 2
  • 3
  • 8
1 2 3
8 9