Fixing solution 2 to use longs instead of ints.