Project Euler #13: Large sum

  • [deleted]
    + 3 comments

    My solution in java :

    {

        Scanner scan = new Scanner(System.in);
        int length = scan.nextInt(); 
        scan.nextLine();
        // using BigInteger : Initializing at 0
        BigInteger sum = new BigInteger("0");
        String temp;
        for(int x=0;x<length;x++){
            temp = scan.nextLine();
            BigInteger tempInt = new BigInteger(temp);      
            sum = sum.add(tempInt);
        }
        String testString =  sum + "";
       System.out.println(testString.substring(0,10));
    

    }