title: Generate random number without duplicate in certain range
body: <p>I'm currently creating an app and it will generate random numbers. So each time it will generate three numbers num1, num2 and num3. These number should not be duplicate. For example if num1 = 1 than num2 and num3 cannot be equal to 1. I've tried this code where it will display three different number ranging from 0-2. And its working. However I would want to generate random number ranging from 1-3, 2-4, 3-5 and so on. So how can I achieve this by using the code below. Please help me since I'm new to this. Thank you.</p>
  
  <pre><code>for(int i=0; i&lt;images.length; i++)
  {
          num[i] = (int)(Math.random()*3);
  
          if (i == 0)
          {
          if(num[i]== 0)
              images[i].setImageResource(R.drawable.zero);
          else if(num[i]==1)
              images[i].setImageResource(R.drawable.one);
          else
              images[i].setImageResource(R.drawable.two);
          }
  
          else
          {
              while (num[i] ==  num[i-1] || num[i] == num[0] )
                  num[i] = (int)(Math.random()*3);
  
  
          if(num[i]==0)
              images[i].setImageResource(R.drawable.zero);
          else if(num[i]==1)
              images[i].setImageResource(R.drawable.one);
          else
              images[i].setImageResource(R.drawable.two);
  
          }
      }
  </code></pre>