Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Perfect Integer Problem

  • 04-02-2004 08: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