package org.geordish; public class Number16 { /** * @param args */ public static void main(String[] args) { int places = 0; int[] answer = new int[1000]; answer[0] = 2; for(int i = 1; i < 1000; i++) { int remainder = 0; for(int j=0; j <= places; j++) { int temp = answer[j]; temp*=2; temp += remainder; if(temp/10 != 0) { if(j == places) { places++; answer[j+1] = temp/10; answer[j] = temp % 10; break; } remainder = temp/10; answer[j] = temp % 10; } else { remainder = 0; answer[j] = temp % 10; } } } int count = 0; for(int i = places; i >= 0; i--) { count += answer[i]; System.out.print(answer[i]); } System.out.println(); System.out.println(count); } }