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 7920991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:25:08+00:00 2026-06-03T16:25:08+00:00

Situation: I am writing a program to solve for primes. I need to solve

  • 0

Situation:

  • I am writing a program to solve for primes. I need to solve problems to the tune of 4x^2+y^2=n, where n is a known variable.
  • Yes, it has to be Ruby.
  • I am comfortable with spending a lot of time on this project.
  • I would, preferably, like to write the solving algorithm for the equations myself and incorporate it as part of this project.

What I would really love:

  • If anyone can provide me with a link to a guide, website, or disambiguation regarding the construction of formal algorithms related specifically to solving algebraic equations, or provide me with information that seems to you the reader that it would help me in my quest.
  • Please don’t suggest I use another language. I would also appreciate if, before answering, you accept that I really, really want to do this. There is no scope or time constraint on this project, and it is not for profit. It is for my own education.

Note:

  • I’m not directly opposed to implementing and using an already extant math library/module/something for Ruby, but the other way is preferable to me.

Closing comments:

The problem is that I know how to solve these equations by hand/with a calculator, but I’m not sure how to solve them in code.

  • 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-06-03T16:25:13+00:00Added an answer on June 3, 2026 at 4:25 pm

    As it seems you are trying to implement the Sieve of Atkin then you are also probably aware that 4x^2+y^2=n is only the first of three equations. I don’t want to spoil your fun and thus the below only implements that one. If you get stuck, just comment this answer and I will get back to you.

    max = 100
    primes = Array.new(max + 1) { false }
    sqrt = Math.sqrt(max)
    1.upto(sqrt) do |x|
      1.upto(sqrt) do |y|
        n = 4 * x**2 + y**2
        primes[n] ^= true if n <= max && (n % 12 == 1 || n % 12 == 5)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation: I am writing a program in C that maintains a number of threads.
I've ran into a strange situation. I'm writing some test cases for my program.
Situation: I am writing a program in C that maintains a number of threads.
Here is my situation. I am writing a program that will store a database.
I'm writing a program in C++ to perform a simulation of particular system. For
Right now I am writing a simulation program which output is formatted according to
I have a situation where an app I'm writing works fine from the IDE
This is the situation. I am writing a backend application in C++ and my
When I'm writing code with QtCreator (2.4.1), I'm very often in this situation: something
I'm writing an app, and in many situations need to have direct access to

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.