Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Perfect Integer Problem

  • 04-02-2004 8:20am
    #1
    Closed Accounts Posts: 439 ✭✭


    You know the perfect integer formula 2^(n-1)x(2^n - 1) where (2^n - 1) is prime, seems to give me really messed up answers like if I put in 11 as the prime or 17, What am I doing wrong here. I'd really like to figure this how as I want to write a C++ program to calculate prime numbers and/or perfect integers, using this formula (there are longer ways to do it, and they work, but I'd also like to try this)


Comments

  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    You're looking for mersenne primes, along the lines of 3, 7, 31, 127 etc.

    I.e, the number must be of the form 2^n-1 AND prime.


  • Closed Accounts Posts: 439 ✭✭Atreides


    is that where n is a whole number?


  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    Yeah. 2^2 - 1 = 3 which is prime, 2^3 - 1 = 7 which is prime, 2^5 - 1 = 31 which is prime, etc, and because they're all primes of that form they're mersenne primes.

    This discusses the connection between mersenne primes and perfect numbers.
    http://www.utm.edu/research/primes/mersenne/


  • Closed Accounts Posts: 439 ✭✭Atreides


    thank you, that makes writing this thing allot easier


Advertisement