Project Euler #1: Multiples of 3 and 5
<p>I just tried to solve the Problem 1 of the Project Euler but I am getting java.util.NoSuchElementException.What is wrong with this code?Can any one please help?</p>
<blockquote>
<p>problem:If we list all the natural numbers below 10 that are multiples &gt;of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.</p>
<p>Find the sum of all the multiples of 3 or 5 below .</p>
<p>Input Format</p>
<p>First line contains T that denotes the number of test cases. This is &gt;followed by  T lines, each containing an integer N, .
Output Format</p>
<p>For each test case, print an integer that denotes the sum of all the &gt;multiples of 3 or 5 below N.</p>
</blockquote>
<pre><code>import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int t=in.nextInt();
        int n[]=new int[t];
        int sum[]=new int[t];
        for(int i=0;i&lt;t;t++)
        {
            n[i]=in.nextInt();
        }
        for(int i=0;i&lt;t;t++)
        {
           sum[i]=0;
           for(int j=2;j&lt;n[i];j++)
           if(j%3==0||j%5==0)
           sum[i]+=j;
           System.out.println(sum[i]);
        }
   }
}
</code></pre>