Euler Problem 56

Easy. Used BigInteger class and long variables just to be on the safe side. Didn’t need to be. Small answer.

    import java.math.*;

    public class Euler56
    {
        public static void main(String[] args)
        {
            Euler56 e = new Euler56();
            System.out.format(“Problem: %s\n”, e.getClass().getName());
            System.out.format(“Answer = %s\n”, e.Problem());
        }
        public String Problem ()
        {
            long max = 0;
            for (int a = 1; a < 100; a++)
                for (int b = 1; b  max)
                        max = GooSum;
                }
            return String.valueOf(max);
        }
        public long digitalSum(String number)
        {
            long sum = 0;
            for (int n = 0; n <= number.length()-1; n++)
                sum += (number.charAt(n)-48);
            return sum;
        }
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s