program problem

This is a discussion on program problem within the C++ Programming forums, part of the General Programming Boards category; I made that prime number thing that I posted about a couple days ago. If you hadn't read that post, ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    241

    Question program problem

    I made that prime number thing that I posted about a couple days ago. If you hadn't read that post, I found the first million prime numbers with it. This took about 5-6 hours on my 933mhz computer, but I had a problem that I couldn't minimize the program. I haven't had too much experience with things like that, and it is probalby a dumb question, but how can I make it possible to minimize a win32 console app when it is doing calculations like that?

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hi,

    As you can probably guess, your program will be using a lot of resources when performing these caculations. When working in a console enviorment you are fairly restricted to fixing this. And i am not to sure of a method that you could apply to it. But i can advise you to learn the win 32 api, then you can use threads to fix this problem, doing this will allow all your programs calcualtions to be performed in a seperate block of code away from you main program, making it minimizable.

    Hope thats some help,

    Cheers
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    I'd change your algorithm, the link I posted in your last thread led to some code that will find the first 910077 prime numbers in around 2 seconds.
    zen

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    241
    I did see your code, but I don't understand how that could actually work correctly and with all prime numbers.

  5. #5
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It wasn't my code (mine only got the prime numbers up to 1000000), but was based on the same principle, only more complex. What prime numbers wouldn't it get?
    zen

  6. #6
    Registered User
    Join Date
    Nov 2001
    Posts
    241
    I just didn't understand how it could work and be faster

  7. #7
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It didn't have to re-calculate each prime number individually, but built a table of prime numbers. It's not something I came up that day, it's been widely recognised as being one of the most efficient methods of establishing prime numbers(unless you want very large amounts) for a couple of thousand years.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Thread Program Problem
    By ZNez in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 11:10 AM
  2. Program Termination Problem
    By dacbo in forum C Programming
    Replies: 3
    Last Post: 01-23-2006, 02:34 AM
  3. Inheritance and Dynamic Memory Program Problem
    By goron350 in forum C++ Programming
    Replies: 1
    Last Post: 07-02-2005, 03:38 PM
  4. Replies: 20
    Last Post: 06-13-2005, 12:53 AM

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