Project-Euler / 13

Problem 13 asks:

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.

Here’s my solution in Java, I left out a lot of the numbers for clarity’s sake:

public class Problem13 {
    private static double[] NUMS = {
        /* 96 other numbers go here... */
    public static void main(String[] args) {
        double sum = 0;
        for (double num : NUMS) sum += num;

It almost feels like cheating by storing the numbers as doubles but it works well because precision is not important and by putting the decimal point after 8 digits I end up with 10 digits after adding together 102 of them.

Last updated on .