public class Solution { public static int solution(int[] l) { int count = 0; for(int i = 0; i < l.length; i++) { for(int j = i + 1; j < l.length; j++) { //since index i < j search onwards for the second number if(l[j] % l[i] == 0) { //if second number is divisible move on the finding the third for(int k = j + 1; k < l.length; k++) { //same logic as loop above for the third number if(l[k] % l[j] == 0) count++; //found a tuple since third is divisible by second } } } } return count; } }