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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:33:14+00:00 2026-05-28T04:33:14+00:00

Let f(N) be the number of points with integer coordinates that are on a

  • 0

Let f(N) be the number of points with integer coordinates that are on
a circle passing through (0,0), (N,0), (0,N), and (N,N).

It can be shown that f(10000) = 36.

What is the sum of all positive integers N  1011 such that
f(N) = 420 ?

Alright, so I think that I have the basic idea for Project Euler number 233. Here is my code:

/*
 * Andrew Koroluk
 */

public class euler233 {
public static void main(String[] args) {
    System.out.println(f(10000));
    System.out.println(f(1328125));
    System.out.println(f(84246500));
    System.out.println(f(248431625));
    //if(true) return;

    double ans = 0;
    for(double N=10000; N<=(Math.pow(10, 11)); N++) {
        //System.out.println(N);
        if( f(N)==420 ) {
            ans+= N;
            System.out.println(N);
        }
    }
    System.out.println(ans);
}
static double f(double N) {
    double ans = 0;     
    double r = Math.sqrt(2*N*N)/2;
    //System.out.println(r*r);
    double r2 = r*r;

    for(int x=1; x<=r; x++) {
        for(int y=1; y<=r; y++) {
            if( x*x + y*y == r2 ) {
                ans+=4;
                break;
            }
        }
    }

    return ans;
}
static boolean isInt(double a) {
    if(a==(int)a) return true;
    return false;
}
}

Basically what I am doing is finding solutions for right triangles inscribed inside the circle, having a hypotenuse the length of the circles diameter. I am not positive that my code is correct.

If it is correct, then my problem is optimizing the f(N) function and optimizing the loop to find numbers for f(N) = 420.

New Code:

public class euler233 {
    static long[] primes;
    public static void main(String[] args) {
        System.out.println(r(1328125));
        Clock c = new Clock();
        System.out.println(f2(10000));
        c.getTimeSeconds();
        c.reset();

        System.out.println(f2(1328125));
        c.getTimeSeconds();
    }
    static long f2(long N) {
        return SquaresR2(N*N);
    }
    static boolean isInt(long a) {
        if(a==(int)a) return true;
        return false;
    }
    static int SquaresR2(long n) {
        //System.out.println("start");
        int sum = 0;
        outer:
        for(int a=0; a<Math.sqrt(n)-1; a++) {
            for(int b=0; b<Math.sqrt(n)-1; b++) {
                if( a*a + b*b == n ) {
                    if(a>b) break outer;
                    sum+=4;
                    System.out.println(n+" = "+a+"^2 + "+b+"^2");
                }
            }
        }
        sum*=2;

        if(Math.sqrt(n)==(int)Math.sqrt(n)) sum+=4;
        return sum;
    }
    static int r(int n) {
        return 4*(d1(n) - d3(n));
    }
    private static int d1(int n) {
        int k=1, sum=0;
        while(true) {
            int d = 4*k+1;
            if(d>n) break;
            if(n%d==0) sum++;
            k++;
        }
        return sum;
    }
    private static int d3(int n) {
        int k=1, sum=0;
        while(true) {
            int d = 4*k+3;
            if(d>n) break;
            if(n%d==0) sum++;
            k++;
        }
        return sum;
    }
}
  • 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-28T04:33:15+00:00Added an answer on May 28, 2026 at 4:33 am

    A few points:

    1. Don’t use floating point numbers for this.
    2. Apart from that, your algorithm is in principle correct.
    3. But it won’t finish before the heat death of the universe.

    You have to find a much better approach, a few hints:

    1. Use only integer maths.
    2. Have a look at an introduction to number theory. Squares and right triangles might be interesting. Oh, and primes.
    3. Have fun.
    4. Let me repeat, number theory (but very basic, you can understand the relevant bits with high school math background; you will have to invest a bit of time though).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say that the company has a large number of separate small to medium
Let's say that I have the following: int a = 2; Number b =
You know those websites that let you type in your checking account number and
I need to find the number, the in and out timecode points and all
Let A[1]<=A[2]<=....<=A[n]. Let X be an arbitrary number. Give an algorithm find all pairs
I have a decimal number (let's call it goal ) and an array of
Let’s say I have a number like 0x448 . In binary this is 0100
Let's say I have a .NET Array of n number of dimensions. I would
Let's imagine I got this: index.php generates form with unpredictable number of inputs with
I have a number of icons used throughout an application - let's take ok/cancel

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.