public static void main(String[] args) {
		long start = System.currentTimeMillis();
		long supersum = 0;
		for (d = 1; d <= 9; d++) {
			List<Interval> valid = getInitialIntervals();
			
			long sum = 0;
			while (valid.size() != 0) {
				List<Interval> newValids = new ArrayList<Interval>();
				for (Interval interval : valid) {
					if (interval.isSingleDigit()) {
						long n = interval.high;
						if (n == f(n,d))
							sum+=n;
						continue;
					}
					for (Interval smaller : interval.split()) {
						if (smaller.isValid())
							newValids.add(smaller);
					}
				}
				
				valid = newValids;
			}
			
			System.out.println(d + " = " +sum);
			supersum+=sum;
		}
		System.out.println(supersum + " (" + (System.currentTimeMillis()-start)+"ms)");
		
	}