 <p>Another version of my solution with ranges:</p> <pre><code>List&lt;int&gt; getUniqueColors(int amount) { final int lowerLimit = 0x10; final int upperLimit = 0xE0; final int colorStep = (upperLimit-lowerLimit)/Math.pow(amount,1f/3); final List&lt;int&gt; colors = new ArrayList&lt;int&gt;(amount); for (int R = lowerLimit;R &lt; upperLimit; R+=colorStep) for (int G = lowerLimit;G &lt; upperLimit; G+=colorStep) for (int B = lowerLimit;B &lt; upperLimit; B+=colorStep) { if (colors.size() &gt;= amount) { //The calculated step is not very precise, so this safeguard is appropriate return colors; } else { int color = (R&lt;&lt;16)+(G&lt;&lt;8)+(B); colors.add(color); } } return colors; } </code></pre> <p>This one is more advance as it generates the colors that differ from each other as much as possible (something like @aiiobe did). </p> <p>Generally we split the range to 3 subranges of red green and blue, calculate how many steps do we need to iterate each of them (by applying a pow(range,1f/3)) and iterate them.</p> <p>Given the number 3 for example, it will generate <code>0x0000B1, 0x00B100, 0x00B1B1</code>. For number 10 it will be: <code>0x000076, 0x0000EC, 0x007600, 0x007676, 0x0076EC, 0x00EC00, 0x00EC76, 0x00ECEC, 0x760000, 0x760076</code></p>