i want to write a program in c to show a perfect numbers between 1 to 10000 and i don't know how to start
Some assumptions: You know C language You know how to formulate these perfect numbers A good place to start is with a pen and paper to outline all of the steps you would take to produce these numbers, then some sudo code, then actual code.
i am having difficulty with the perfect numbers concepts
Well a quick search through wikipedia shows that a perfect number is 2^(p−1)(2p−1), so this could be done easily with a loop.
The previoius is for even perfect numbers and from the looks of it finding an odd perfect number will require quite a bit more work.
The program has no user input. Using the 'Mersenne exponential method' involves the simple implementation of a formula with a lookup table. This bypasses the usefulness of the assignment - namely the learning of loop and conditional statements (while, at the same time, avoiding the use of pointers). Therefore, using this method is not adequate to pass the assignment - you must test each integer individually for its 'perfectness'.
Well you could start with a nested loop: for (i = 1; i< 1000;i++){ for(j=1; j< 100; j++){ num = i^j(i^(j+1)-1); printf("The number %d to the power of %d is: %d\n",i, j, num); } } This would run every number between 1 and 1000 through the formula described for the even set of perfect numbers. As for the check, that gets a little more specific and depends on what all the assignment entails.
http://en.wikipedia.org/wiki/Perfect_number You will also need to check if the number (j) is prime.
thank you my friend i am gone do some reading and then start trying
:) You're welcome.
well start to write your static array , that would be a really good start :)
i ges u gat all help u needed......
Join our real-time social learning platform and learn together with your friends!