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

Java perfect numbers nested for loop

I made this with the help of a friend, in order to find the perfect numbers(numbers where sum of divisors = original number) sum of up to the number that the user enters. Can someone help me convert it so that it prints each number on a line, even…
cooldudsk
  • 65
  • 1
  • 4
  • 13
0
votes
1 answer

Project Euler #23 (Java). I can't figure out what's wrong. Answer is off by 64

The problem is: 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…
psBDS
  • 341
  • 1
  • 3
  • 7
0
votes
1 answer

logical error project euler 23?

I am unable to get the right output for the following: 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…
vvv
  • 53
  • 1
  • 7
0
votes
3 answers

Calculating Perfect Numbers

See, I have a boolean method that gets the divisors that work by moding the number by a divisor that is checked and determined true by a for loop (not the first one, that just loops the program for a determined amount of input. I'm not sure if…
0
votes
1 answer

How can i make my program faster .(perfect number finder ) in java?

Can I make it faster to find perfect numbers? I tried to make it faster with array and another algorithm, but none made it faster. public class Perfect{ static long perfectNumber; static long startTime = System.nanoTime(); static long…
0
votes
2 answers

perfect numbers formatting

I got this homework about perfect numbers between 1-1000, where a number equals to a sum of its divisors. I've found the right code to check if a number is a perfect number and found that those numbers were 1, 6, 28, 496 (I don't know why 1 is…
0
votes
2 answers

Find Perfect Number from 1-9999. Exercise from The Art and Science of Java

I am trying to find the perfect number by find out all their divisors. If their sum is equal to the number, then print out the the number. But apparently it's not working. import acm.program.*; public class PerfectNumber extends ConsoleProgram{ …
JackDee
  • 1
  • 1
  • 4
0
votes
1 answer

How to find all perfect numbers in specific interval in c++?

I want to find all perfect numbers from interval x to y. Any help how can I do that ?
user2943407
  • 409
  • 3
  • 5
  • 13
0
votes
4 answers

What's wrong with this perfect number code?

I wrote a perfect number program, but when I run it, it outputs that every number is perfect. Please help me find my mistake. This is my server code: public class Perfect { private int number; public Perfect() { number = 0; …
0
votes
6 answers

Perfect numbers

I attempted this program in java for a bounded constant input for upto 1000 integers. Not getting the expected output :( package perfect.numbers; import java.util.ArrayList; public class PerfectNumbers { public static void main(String[] args)…
Prateek Kiran
  • 35
  • 1
  • 7
0
votes
2 answers

need some assistance with a perfect number exercise in C#

(this isn't homework, just an exercise in the book I'm using) "An integer is said to be a perfect number if its factors, including one (but not the number itself), sum to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3.…
user2723261
  • 541
  • 2
  • 7
  • 12
0
votes
1 answer

Project Euler #23 - What does this mean?

http://projecteuler.net/problem=23 I am not looking for an answer . but can somebody explain me what does this means ? As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two…
aked
  • 5,625
  • 2
  • 28
  • 33
0
votes
3 answers

Does opening a file related to the program also stop the program?

I have this program that is supposed to search for perfect numbers. (X is a perfect number if the sum of all numbers that divide X, divided by 2 is equal to X) sum/2 = x Now It has found the first four, which were known in Ancient Greece, so it's…
Gloripaxis
  • 1,026
  • 1
  • 9
  • 9
0
votes
2 answers

Why do I get the error "Floating point exception"?

I am trying to write a code that finds perfect numbers lower than the user's input. Sample of correct output: Enter a positive integer: 100 6 is a perfect number 28 is a perfect number There are no more perfect numbers less than or equal to…
0
votes
7 answers

Perfect number method

This program is supposed to take user input and determine whether or not it is a perfect number. When I try to compile it, I get the error Method testPerfect in class scalvert_Perfect cannot be applied to given types; testPerfect(num); required…
user1858350
  • 115
  • 1
  • 4
  • 10
1 2 3
8 9