Goldbach Conjecture

This is a discussion on Goldbach Conjecture within the C++ Programming forums, part of the General Programming Boards category; Code: cout << i << " " << j << " " << number-(i+j) << endl;...

  1. #16
    Registered User
    Join Date
    Mar 2005
    Posts
    140
    Code:
    cout << i << " " << j  << " " << number-(i+j) << endl;
    Last edited by spydoor; 03-17-2005 at 02:14 PM.

  2. #17
    Registered User
    Join Date
    Feb 2005
    Posts
    59
    Great, thanks. It gives me every possible prime number combination now I just have to figure out to get only one. Thanks for your help.

    For example I let it compute 346
    I only want the first answer that it computes. Is there anyway to do that?
    Last edited by StarOrbs; 03-17-2005 at 02:59 PM.

  3. #18
    Registered User
    Join Date
    Feb 2005
    Posts
    59
    Nevermind I figured it out. Thanks a lot everyone!

  4. #19
    Registered User
    Join Date
    Feb 2005
    Posts
    59
    Dang, I finally get that one working and my sum of two primes doesn't work. Is there anyway to change the sum of three primes function to calculate the sum of two primes?

  5. #20
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Sure. Just take out one level of the nested loops, i.e. loop from 1 to i, and for each prime 'i' you loop from 1 to (num - i), checking if (num - i) is prime.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Goldbach's Conjecture
    By cashmerelc in forum C Programming
    Replies: 7
    Last Post: 07-19-2010, 11:41 PM
  2. Goldbach's conjecture
    By dcwang3 in forum C Programming
    Replies: 10
    Last Post: 10-14-2008, 02:34 AM
  3. Godbach conjecture!!
    By Leojeen in forum C Programming
    Replies: 10
    Last Post: 04-20-2008, 07:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21