Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:53:14+00:00 2026-05-25T17:53:14+00:00

I´m sorry but I have to ask a very simple question. My problem is

  • 0

I´m sorry but I have to ask a very simple question.
My problem is that I want to generate the prime numbers until a maximum number.

here´s my code:

    for (int i = 2; i <= max - 1; i++)
        {
            System.Threading.Thread.Sleep(1000);
            if (Progress != null)
            {
                if (max%i == 0)
                    Console.WriteLine(i);
            }
        }  

My code doesn´t work and I don´t know why..

Can you please help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:53:15+00:00Added an answer on May 25, 2026 at 5:53 pm

    Hint 1: Algorithm optimization

    You don’t need to go all the way to the max number. You need only to go to its square root.

    Think with me with this example: if 100 is divided by 50, it was first caught as being divided by 2. So you only need to go up to 10, any divisor you find after that, its counterpart would have been found before.

    But this is only how you optimally find whether a specific number is prime or not.

    Hint 2: IsNumberPrime() Method

    First of all, you have to have a method to determine whether a specific number is prime or not. Keep in mind hint 1 here.

    Hint 3: Doing It Right This Time

    After you have followed hints 1 and 2, now you can loop and determine the highest prime number lower then your max number.

    Conclusion

    Sorry, no code here, just general orientation. Doing your homework for you will not help you. This answer will.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for wanting to ask a simple question. I have my initial view loaded
I am very sorry if I ask a wrong question but I really need
I'm sorry that I have to ask that here, but I haven't found a
I am sorry I have already asked this question on Superuser, but nobody answers
Sorry for the simple question but I feel like there's a smarter way to
Hi this question or problem i have its very hard i have search and
I am very new to this and i am sorry to ask this question.
I'm sorry to ask such a simple question with such a small amount of
I'm sad to have to ask this question, but I'm not even sure of
sorry to have to ask, but I don't know what this term means, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.