• Post Reply Bookmark Topic Watch Topic
  • New Topic

Euler Problem 2  RSS feed

 
Keith Eliot
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to do Euler problem 2, but being a proper noob I have some questions and google isn't helping me.

Is there a way to use Phi (and for that matter, Pi) in java?

How can I put the output from an interger variable into an array? If I have a loop like: for(x=5, x<1000, x++){and put the output of x each time into an array?}

Thanks!
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have to:
1. Declare a variable which would hold the array elements- something like int[] myArray = new int[1000];
2. Use index to assign a value to the array elements - something like myArray[10] = 1000;

For more details please read Arrays Tutorials
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith Eliot wrote:Is there a way to use Phi (and for that matter, Pi) in java?

java.lang.Math has PI and E as a constant. Phi isn't there, but phi = (1 + sqrt(5))/2, so there is a method there that will help you construct it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!