title: Find all combinations 6 number JAVA
body: <p>I have a problem with combinations. </p>
  
  <p>I need increment last number from 6 number and if the last number is 50 penultimate increment by 1.</p>
  
  <p>I have this code which find all permutations. But I want combinations. </p>
  
  <p>I need so if already program generate 1 2 3 4 5 6 never again generate combination this number so 1 2 3 4 5 6 it's the same like 6 5 4 3 2 1 and 6 1 2 3 4 5 ... </p>
  
  <pre><code>hladaj[N-2]++;
      while(((hladaj[N-3]==hladaj[N-2])||(hladaj[N-2]==hladaj[N-4])||(hladaj[N-2]==hladaj[N-5])||(hladaj[N-2]==hladaj[N-6])||(hladaj[N-2]==hladaj[N-7]))){
          hladaj[N-2]++;
      }
  
      if (hladaj[N-2]&gt;MAXC) {
          hladaj[N-2]=hladaj[N-2]-MAXC;           
          hladaj[N-3]++;
  
          while(((hladaj[N-3]==hladaj[N-2])||(hladaj[N-2]==hladaj[N-4])||(hladaj[N-2]==hladaj[N-5])||(hladaj[N-2]==hladaj[N-6])||(hladaj[N-2]==hladaj[N-7]))){
              hladaj[N-2]++;
          }
          while(((hladaj[N-3]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-4])||(hladaj[N-3]==hladaj[N-5])||(hladaj[N-3]==hladaj[N-6])||(hladaj[N-3]==hladaj[N-7]))){
              hladaj[N-3]++;
          }
  
          if (hladaj[N-3]&gt;MAXC) {
              hladaj[N-3]=hladaj[N-3]-MAXC;                   
              hladaj[N-4]++;
              while(((hladaj[N-3]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-4])||(hladaj[N-3]==hladaj[N-5])||(hladaj[N-3]==hladaj[N-6])||(hladaj[N-3]==hladaj[N-7]))){
                  hladaj[N-3]++;
              }
  
              while(((hladaj[N-4]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-4])||(hladaj[N-4]==hladaj[N-5])||(hladaj[N-4]==hladaj[N-6])||(hladaj[N-4]==hladaj[N-7]))){
                  hladaj[N-4]++;
              }           
  
  
              if (hladaj[N-4]&gt;MAXC) {
                  hladaj[N-4]=hladaj[N-4]-MAXC;
                  hladaj[N-5]++;
  
                  while(((hladaj[N-4]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-4])||(hladaj[N-4]==hladaj[N-5])||(hladaj[N-4]==hladaj[N-6])||(hladaj[N-4]==hladaj[N-7]))){
                      hladaj[N-4]++;
                  }   
  
                  while(((hladaj[N-5]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-5])||(hladaj[N-4]==hladaj[N-5])||(hladaj[N-5]==hladaj[N-6])||(hladaj[N-5]==hladaj[N-7]))){
                      hladaj[N-5]++;
                  }
  
  
                  if (hladaj[N-5]&gt;MAXC) {
                      hladaj[N-5]=hladaj[N-5]-MAXC;
                      hladaj[N-6]++;
  
                      while(((hladaj[N-5]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-5])||(hladaj[N-4]==hladaj[N-5])||(hladaj[N-5]==hladaj[N-6])||(hladaj[N-5]==hladaj[N-7]))){
                          hladaj[N-5]++;
                      }
  
                      while(((hladaj[N-6]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-6])||(hladaj[N-4]==hladaj[N-6])||(hladaj[N-5]==hladaj[N-6])||(hladaj[N-6]==hladaj[N-7]))){
                          hladaj[N-6]++;
                      }
  
                      if (hladaj[N-6]&gt;MAXC) {
                          hladaj[N-6]=hladaj[N-6]-MAXC;
                          hladaj[N-7]++;
  
                          while(((hladaj[N-6]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-6])||(hladaj[N-4]==hladaj[N-6])||(hladaj[N-5]==hladaj[N-6])||(hladaj[N-6]==hladaj[N-7]))){
                              hladaj[N-6]++;
                          }
  
  
                          while(((hladaj[N-7]==hladaj[N-2])||(hladaj[N-3]==hladaj[N-7])||(hladaj[N-4]==hladaj[N-7])||(hladaj[N-5]==hladaj[N-7])||(hladaj[N-6]==hladaj[N-7]))){
                              hladaj[N-7]++;
                          }
  
                          if (hladaj[N-7]&gt;MAXC) {
                              hladaj[N-7]=MAXC;
                              return true;                                    
                          }                                   
                      }
                  }                   
              }               
          }
  </code></pre>
  
  <p>This code generate 1 2 3 4 5 6 , 6 5 4 3 2 1 I need If generate one of combinations this combinations no generate again. </p>
  
  <p>Please you have some ideas for modify my code or... </p>
  
  <p>(I need all of generated number[6] processed, but now I waste time because I work 120 times with same numbers.)</p>
  
  <p>Thanks</p>