perfect numbers Programming Software Development by max.yevs I'm trying to make a perfect numbers script but having almost no success... Perfect numbers are those whose factors add up to twice the… i was trying to do it: [code=python]print ("Perfect Numbers") a = 0 b = [] while True: for n in range… Re: perfect numbers Programming Software Development by max.yevs … to go ahead and use it... [code=python]print ("Perfect Numbers") k = 0 while True: a = 2**(2*k+1…(a) k += 1[/code] it will come up with 7 numbers pretty much instantly, im sure it can realistically do 10… have made a world [URL="http://amicable.homepage.dk/perfect.htm"]discovery[/URL]! Re: perfect numbers Programming Software Development by max.yevs …think you meant the 'while' loop... [code=python]print ("Perfect Numbers") a = 0 while True: b = [] for n … print(a) a += 1[/code] it only finds three numbers: 0 , 6, and 28 which is accurate because 6 …and 28 are the first two numbers... after then it freezes, which is expectable because … Re: perfect numbers Programming Software Development by max.yevs like this? [code=python]print ("Perfect Numbers") a = 1 while True: x = 0 for n in …, even though it still just immediately finds the first 4 numbers.... this without lists way is the way i was trying… this, its always going to have to factorize very large numbers, it would take something extremely clever... Re: perfect numbers Programming Software Development by max.yevs … to the square root of a... [code=python]print ("Perfect Numbers") a = 1 b = [] while True: for n in range… like i hoped that it would just scroll through the numbers... Re: perfect numbers Programming Software Development by adam1122 … with comments where there are changes. [code=python]print ("Perfect Numbers") a = 1 #No need to start at 0 b… Re: perfect numbers Programming Software Development by max.yevs … found 8128 after like three seconds... [code=python]print ("Perfect Numbers") a = 1 b = [] while True: for n in range… Re: perfect numbers Programming Software Development by max.yevs …,084,303,638,130,997,321,548,169,216! maybe perfect numbers were not the best list to choose... it might be… perfect numbers Programming Software Development by leegeorg07 … again! at school we were learning about perfect numbers and i thought it would be useful to… if b==n: print n, "is not a perfect number" else: print "halfway there" if… (most recent call last): File "C:\Python25\perfect nums.py", line 22, in <module>… perfect numbers Programming Software Development by plike922 …() { int i, d, t; printf("This program generates all perfect numbers from 1 to 100.\n"); t = 0; for (i… Re: perfect numbers . . ! Programming Software Development by redmaverick perfect numbers are: The perfect number is 6 The perfect number is 28 The perfect number is 496 The perfectperfect numbers use for loop to check first 10000 numbers from which to get the first 4 perfect numbers…use if statement to check for perfect number and if count is less… Re: perfect numbers . . ! Programming Software Development by redmaverick … the user. You are checking for perfect numbers from 1 to 10000. also to check for perfect number you should use the condition… Re: Questions about Perfect Numbers ? Programming Software Development by Banfa Perfect numbers are few and far between the next perfect number after 8128 is 33550336 which is rather greater than 1000000 so your program can not find it. It would appear that your program may be working. Re: perfect numbers Programming Software Development by jlm699 … whole point of the loop is testing different numbers to see if they're perfect... like testing 1, then a +=1, …for loop, not the while loop. You're testing different numbers using [ICODE]a[/ICODE], which is incremented at the … suggested moving the [ICODE]sum(b)[/ICODE] and subsequent perfect number check to after the for loop to save processing… Re: perfect numbers Programming Software Development by max.yevs … whole point of the loop is testing different numbers to see if they're perfect... like testing 1, then a +=1, or… Re: perfect numbers Programming Software Development by woooee … use modulo or divmod to find the numbers that you can divide the given number by… == 0. You will be working with single numbers which is less confusing. Actually, you can use… the (given number / 2) since all numbers greater than the halfway point can't be divided… into to the number. Then sum these numbers and see if they add up to the… Re: perfect numbers Programming Software Development by woooee … list of 1-256 and reference the list for those numbers, so if you try: x=257 print x is 257… Re: perfect numbers Programming Software Development by adam1122 … you one very simple optimization (don't loop through all numbers [0,a]). Try creating a program that gets the sum… Re: perfect numbers Programming Software Development by max.yevs … the exception of n = m [which will happen for square numbers], then only n is added) so like say the number… Re: perfect numbers Programming Software Development by leegeorg07 … [:40] if b==n: print n, "is not a perfect number" else: print "halfway there" if b…: print n, "is a perfect number"[/icode] you can see that all the numbers smaller than 6 are thought of… Re: perfect numbers Programming Software Development by leegeorg07 ok can you give me any advice on how to change it to multiply all of the numbers in the list together? Re: perfect numbers Programming Software Development by bvdet … factors a few months ago. You only need to check numbers up to sqrt(number).[code=Python]def factors(num): outList… Re: perfect numbers Programming Software Development by taitos7 …) == number): print "the number if perfect" else: print "the number isn't perfect" for number in range (1000…[x] if ((result / 2) == number): print "the %2d is perfect" %(number) else: print "the %2d isn't… help with perfect numbers Programming Software Development by dennisme …perfFinder { public void doPerfNum() { // find all the perfect numbers 1-upper range int j=1; boolean ans; Scanner inp…main(String[] args) { // create an object to find perfect numbers perfFinder findThem = new perfFinder(); //call the method to … Re: help with perfect numbers Programming Software Development by dennisme … class perfFinder { public void doPerfNum() { // find all the perfect numbers 1-upper range int j=1; boolean ans; Scanner inp…void main(String[] args) { // create an object to find perfect numbers perfFinder findThem = new perfFinder(); //call the method to "… exercise does not require the factors only the perfect numbers. So this should work? Re: help with perfect numbers Programming Software Development by dennisme Where does that code fragment go? If Im calculating the perfect numbers do i still need this: public boolean isPerf(int n){ if( n==6 || n==28 ) return true; else return false; }// end isPe Re: help with perfect numbers Programming Software Development by deviliq seriously, 6 and 28 aren't the only perfect numbers ahaha! Re: help with perfect numbers Programming Software Development by dennisme I am well aware the 6 and 28 and not the only perfect numbers. I'm not sure how you remotely fount that amusing. If you read the the first post I can make it run with a loop but the exercise is with methods and functions, two classes one project. it was an example. End of story. Questions about Perfect Numbers ? Programming Software Development by Madmark88 …trying to improve my skill.i have some question about perfect numbers i searched forum but results were about C++. question… is this code finds perfect numbers between 1 to 1000000. but its not working after …8128 which is perfect number. [CODE]#include<stdio.h> #include&… Prime and Perfect Numbers to 1000 Programming Software Development by sibwolf …output a list of all prime numbers and perfect numbers between 1 and 1000. Have …aDiv++) { //Found Divisor if (aCurrentNum % aDiv == 0) { //Add for Perfect Number if (aDiv != aCurrentNum) { aPerfectNum += aDiv; } } } if (…