I'm following in the footsteps of the 100K people who have gone before me in trying to solve some of the project Euler problems. The challenge is to calculate the highest prime factor of a given number. My current solution works perfectly for integers... the problem is that project euler wants me to calculate a long, and I'm not sure I can use longs in ArrayLists.

import java.util.*; public class PrimeFactors { public static List<Integer> primeFactors(int numbers) { int j = numbers; List<Integer> factors = new ArrayList<Integer>(); for (int i = 2; i <= j / i; i++) { while (j % i == 0) { factors.add(i); j /= i; } } if (j > 1) { factors.add(j); } return factors; } public static void main(String[] args) { int inputValue = 0; if (args.length > 0) { inputValue = Integer.parseInt(args[0]); } else { System.out.println("Please enter a value."); } for (Integer integer : primeFactors(inputValue)) { System.out.println(integer); } } }

Much appreciated if somebody could help point me in the right direction.