Mutual Indivisibility

  • + 1 comment
    int range = (b-a)+1;
                int limit = (range-x)+1;
                int[] arr = new int[x];
                int start=a;
                for(int i=0;i<limit;i++){
                    
                    int inside = start;
                    
                    for(int j=0;j<x;j++){
                        arr[j] = inside;
                        inside++;
                    }
                    int check = arr[0]*2;
                    if(arr[x-1]>=check && arr.length==range ){
                        int ans = -1;
                        System.out.print(ans);
                        break;
                    }else if(arr[x-1]<check){
                        for(int k=0;k<x;k++){ 
                            System.out.print(arr[k]+" ");
                        }
                    System.out.println("");
                    break;    
                    }
                        
                    start++;    
       
                    }
    

    Why set [3,4,5] is not accepted as avalid output when it was clearly mentioned it is also one of the valid output in explanation.

    image

    image