well if the highest cycle is 476 for all numbers between 1 and 1,000,000....
i added some print statements to figure this out. i used a print statement to return me the number that i was on when the max cycle went above 475 and got back these 6 numbers:
626331
704623
837799
910107
927003
939497
so i added an if statement to print all of the results as it went through each of these, but the console only holds so much. but you can view the results for the last 2 or 3. i just dont understand how it can work correctly for all of the other numbers but not these 6, especially now that im using long.
also im not sure i know what you mean by intermediate step... is there anyway you could be more specific or elaborate, please?
thanks so much for your help so far, i hope i can figure out this problem,
respectfully,
Taylor Zachary
heres my updated code:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String args[]) throws IOException {
//File file = new File("inputfile.txt");
//int[] iList = new int[4];
//int[] jList = new int[4];
ArrayList<Integer> ial = new ArrayList<Integer>();
ArrayList<Integer> jal = new ArrayList<Integer>();
int counter =0;
int k = 0;
String y="";
String z="";
int first=0;
int second=0;
int max=1;
int highest=0;
int highestCycle=0;
int temp=0;
long temp2 = 0;
long temp3 = 0;
int[] myCycles = new int[counter];
String output="";
ArrayList<String> myList = new ArrayList<String>();
final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=reader.readLine()) != null){
highest = 0;
max = 0;
k = line.indexOf(" ");
//System.out.println(k);
y = line.substring(0, k);
//System.out.println(y);
z = line.substring(k+1, line.length());
//System.out.println(z);
first = (Integer.parseInt(y));
//System.out.println("First: " + first);
second = (Integer.parseInt(z));
//System.out.println("Second: " + second);
temp = first;
//System.out.println("temp: " + temp);
//System.exit(1);
while(temp<second){
//System.out.println("temp: " + temp);
if(max>highest){
highest=max;
}
//System.out.println("highest: " + highest);
temp2 = temp;
/*if(temp>113382){
System.out.println("KKTEMP2: " + temp2);
System.out.println("**TEMP: " + temp);
}*/
max=1;
temp3 = temp2;
if(temp == 626331 || temp == 704623 || temp == 837799 || temp == 910107 || temp == 927003 || temp == 939497){
System.out.println("Current Number: " + temp);
}
while(temp3!=1){
/*if(temp2>113382){
System.out.println("temp2: " + temp2);
}*/
if(temp == 626331 || temp == 704623 || temp == 837799 || temp == 910107 || temp == 927003 || temp == 939497){
System.out.println("Current value: " + temp3);
}
if(temp3%2 == 0){
temp3 = temp3/2;
/*if(temp2>113382){
System.out.println("first: " + temp3);
}*/
}else{
/*if(temp2>113380){
System.out.println("$$Check: " + temp3);
System.out.println("TEST: " + (temp3*3) );
}*/
temp3 = ((temp3*3)+1);
/*if(temp2>113382){
System.out.println("^second: " + temp3);
}*/
}
if(max > 475){
//System.out.println("temp3***: " + temp3);
//System.out.println("MAX: " + max);
}
max++;
if(temp == 626331 || temp == 704623 || temp == 837799 || temp == 910107 || temp == 927003 || temp == 939497){
System.out.println("Current value: " + temp3);
}
//System.out.println("MAX: " + max);
if(max>highest){
if(max > 475){
//System.out.println("\n\n##: " + temp);
}
highest=max;
}
}
if(max > 475){
//System.out.println("\n\ntemp: " + temp);
//System.out.println("Max: " + max);
//System.out.println("temp3: " + temp3);
}
temp++;
}
if(temp == 626331 || temp == 704623 || temp == 837799 || temp == 910107 || temp == 927003 || temp == 939497){
System.out.println("max: " + max);
}
output = first +" " + second + " " + highest;
output.trim();
System.out.println(output);
}
}
}