Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C++ (https://www.askmehelpdesk.com/forumdisplay.php?f=439)
-   -   Coding a c++ program (https://www.askmehelpdesk.com/showthread.php?t=145663)

  • Oct 27, 2007, 05:40 PM
    ziba
    coding a c++ program
    I need a fast help to code the following program which is really easy:

    I have to develop a program to analyze one or more numbers entered by a user and see if the number is a prime # or a perfect # and out put a list of divisors of all perfect numbers and noneprime numbers.

    Hint: A prime # is a # whose only exact divisors are 1 and the number itself(such 2,3,5,7) and a perfect # is a # whose exact divisors (except the number itself) sum to equal the number.(For example #6 has 3 divisors(not including 6). The divisors of 6(1,2,3)sum to equal the number.

    I will appreciate your help if u give me the answer within 24 hours.
  • Oct 27, 2007, 06:05 PM
    asterisk_man
    We're not here to do your homework. Next time try asking questions before the assignment is due tomorrow. We can help you with questions and review your answer but we won't do the work for you.
  • Nov 22, 2007, 11:04 AM
    red_cartoon
    If you are new to programming, then this is certainly not a good idea to start working on these problem just the day before submission. I hope you are in a much better situation than that.

    For checking whether a number is prime or not, you run a loop I = 1 to I = sqrt(n) and see if I divides n without any reminder. If none of these can divide n without a reminder then n is prime.

    For perfect number checking, loop from 1 to n and collect the divisors as you go through the loop. Add them to see whether they sum up to n or not. That's it.

  • All times are GMT -7. The time now is 11:18 AM.