Keith Eliot

Greenhorn

Posts: 2

posted 5 years ago

Hello,

I'm trying to do Euler problem 2, but being a

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!

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!

posted 5 years ago

So you have to:

1. Declare a variable which would hold the array elements- something like

2. Use index to assign a value to the array elements - something like

For more details please read Arrays Tutorials

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

Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook

Matthew Brown

Bartender

Posts: 4568

9

posted 5 years ago

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.

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. |