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
-1
votes
2 answers

How can I make ProjectEuler 23 Solution faster

This is what I have. It is solving the problem, but taking forever. Can I divide the last loop 0 to 28123 into half and run them simultaneously somehow to make it faster, and then in the end add the two sums to get the final result? Will "thread"…
user1478983
  • 95
  • 1
  • 11
-1
votes
2 answers

Project Euler 23: Answer is off by 995

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 perfect number. A number n is called…
nishkrish
  • 31
  • 4
-1
votes
1 answer

I need help generating a list of perfect numbers like 6,28, and 496. (My for-loop is a bit off in my second function)

I know my first function is correct and that it can validate a perfect number (i.e. 6, 28, 496). However, I'm struggling printing a list of perfect numbers. Meaning if I call listPerfect(500), I can't list the numbers 6,28, and 496. What am I…
js_55
  • 177
  • 1
  • 1
  • 9
-1
votes
2 answers

abundant sums, logic

I have been working on the problem below but I get the wrong answer. What is wrong with my logic? 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…
Toko Laskis
  • 23
  • 1
  • 1
  • 5
-1
votes
1 answer

Can someone give me some tips on using arrays to print out abundant, perfect, and deficient numbers in C++?

Here is some of my code: I am having trouble figuring out how to pass an array through the perfectTest int. I have the options that if n is -1 than it prints out that it is a deficient number, if n is 0 than it prints out that it is a perfect…
rookkin
  • 9
  • 2
-2
votes
3 answers

Creating a function that checks perfect numbers python

I've been trying to create a function that checks for perfect numbers, I've used many of the resources I found here, but they don't seem to work for some reason. In my assignment, I'm required to find different types of numbers in a given range…
altalio
  • 27
  • 7
-2
votes
1 answer

Program to print the first 10 perfect squares

I am trying to go over the natural number and test each natural number if it is the perfect square print that number, but my only condition is that print only first 10 perfect square numbers. i =2 n=1 #used for counting while 10>=n: for j…
Raj
  • 1
  • 1
  • 3
-2
votes
1 answer

Not counting number of perfect numbers within a range?

I want to find the number of the perfect numbers in a range. This is what i have done so far. #include using namespace std; int main() { // cout<<"Hello World"; int sum = 0; int count = 0; int x,y; cout<<"Enter the first…
-2
votes
1 answer

Program to print first 5 perfect numbers, is printing 2096128?? C++

So this program will print perfect numbers, but one of them, 2096128, is being printed for some reason? Would really appreciate some help figuring out what is happening! Thank you! I can't figure out why one non perfect number is finding it way into…
Catz
  • 11
  • 5
-2
votes
1 answer

Perfect Number between 1 and 1000

I try to find the perfect number between 1 and 1000, i wrote this code but it didn't work! what is wrong? public class Perfect { public static void main(String[]args) { int sum=0; for (int n = 1; n < 1000; n++) { for…
Sadra Reihan
  • 3
  • 1
  • 2
-2
votes
2 answers

Perfect numbers. Something wrong

I am trying to accomplish a task. To print 4 perfect numbers which are between 1 and 10000. In number theory, 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…
Contempt
  • 189
  • 2
  • 5
  • 14
-3
votes
2 answers

Smart algorithm for finding perfect numbers

Is there an algorithm that is quicker than O(N^2) for finding perfect numbers from a sample 1:N? Or any general speed improvements to do less computation? I know we can remove odd numbers from the sample if we assume they are not perfect (unproven…
fvim
  • 51
  • 6
-3
votes
2 answers

Calling Boolean function in C++

Here is my program, which aims to show whether the input integer is a perfect number or not. It is required to use Boolean function and call it back in main function. However, after running the trial, there is no output. Can anyone help out this…
Paulpaul
  • 11
  • 1
  • 1
  • 2
-4
votes
6 answers

Java program for perfect numbers between a range

I wrote this java program for printing all three digit perfect numbers, however it doesn't print anything except "PERFECT NUMBERS" and "Total : 0". Arrays and functions not allowed (school assignment). class PerFect { public static void…
-5
votes
2 answers

Why is this algorithm in Python is printing the result several times?

This algorithm, which is attached and written below, is printing the result multiple times. It is an algorithm to find out if the received number is a perfect number, that is, if the sum of the divisors of that number results in the number itself,…
John
  • 49
  • 7
1 2 3
8
9