Ugly numbers dp

import java.util.*;
public class Main {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int t = sc.nextInt();
	while(t-->0) {
		int n = sc.nextInt();
		System.out.println(getUgly(n));
	}
}

public static int getUgly(int n) {
	
	int[] ugly = new int[n];
	int i2=0,i3=0,i5=0;
	int nextMultipleOf2 = 2;
	int nextMultipleOf3 = 3;
	int nextMultipleOf5 = 5;
	int nextUglyNo = 1;
	
	ugly[0] = 1;
	
	for(int i=1;i<n;i++) {
		nextUglyNo = Math.min(nextMultipleOf2, Math.min(nextMultipleOf3, nextMultipleOf5));
		
		ugly[i] = nextUglyNo;
		
		if(nextUglyNo == nextMultipleOf2) {
			i2++;
			nextMultipleOf2 = ugly[i2]*2;
		}
		
		if(nextUglyNo == nextMultipleOf3) {
			i3++;
			nextMultipleOf3 = ugly[i3]*3;
		}
		
		if(nextUglyNo == nextMultipleOf5) {
			i5++;
			nextMultipleOf5 = ugly[i5]*5;
		}
	}
	
	return nextUglyNo;
}

}

//sir Iā€™m getting correct answer for the example but not for the test cases

@Siddharth_sharma1808,
https://ide.codingblocks.com/s/233033 corrected code.
Use long instead of int.