Jump to content

List of numbers

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Quantum++

Quantum++

    Newbie

  • Members
  • Pip
  • 2 posts
How can I find/program a list of:
We only operate with natural numbers.

1. The prime numbers < 10 000
2. x = a^2 + b^2 < 10 000
3. x = a^3 + b^3 < 10 000
4. x = a^2 + b^2 + c^2 < 10 000
5. x = a^3 + b^3 + c^3 < 10 000

Thank you.

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
1)
Do you have any code allready?
If not:
Do you know how to code it for a single number?

2)
        int x=0, a=0, b=0;
        while(x<10000){
            while(x<10000){
                x = (int) (java.lang.Math.pow(a,2) + java.lang.Math.pow(b,2));
                if(x<10000)
                    System.out.println(x +" = " + a +"^2 + "+ b++ +"^2");
            }
            b=0;
            a++;
            x=(int) (java.lang.Math.pow(a,2));
        }


If you understand what's happening in #2. 3, 4 and 5 should be no problem. (especially not 3 )

#3
Quantum++

Quantum++

    Newbie

  • Members
  • Pip
  • 2 posts
Thanks for your respons!

I dont have the code already.
Now I will try your code i Blue J Java.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users