Project Euler #130: Composites with prime repunit property

  • + 0 comments

    my entire code is right but i dont know why its failing i have checked taking more complex values can anyone help me out with this!

    Scanner sc=new Scanner(System.in); long num=1; int j,val,k,c=0,r=0; int n1,n2; n1=sc.nextInt(); n2=sc.nextInt(); int arr[]=new int[50]; for(int i=4;i<22;i++) { j=i; num=1; c=0; while(j>1) { num=num+(long)(Math.pow(10, j-1)); j--;
    }
    k=5; while(k5;x--) { if(k%x==0 && (k-1)%i==0) { c++; break; }
    } if(c>0) { arr[r]=k; r++; } } k++; } } Arrays.sort(arr);

        for(int u=0;u<arr.length;u++)
        {
            if( u<arr.length-1 && arr[u]==arr[u+1] )
                arr[u+1]=n2+1;
            if(arr[u]<n2 && arr[u]>n1)
                System.out.println(arr[u]);
        }