Hi, I am suppose to create a code that takes the values between 1-1000 and produces the hailstone sequence for them, then it prints out the initial value that produced the longest sequence along with the sequence's length. I have tried to use an array but it didn't seem to work, so I tried a simpler approach but it's not working either:

```
public class one {
public static void main(String[]args){
int first=1;
int last=1000;
int max=0;
int length=0;
while (first<=last){
while (first!=1)
{
if (first%2== 0)
{
first= first / 2;
length++;
}
if (first % 2 != 0)
{
first = (3 * first) + 1;
length++;
}
}
first++;
break;
}
if (max < length)
{
max = length;
}
System.out.println(max+first);
}
}
```

Thank you for any help!