decimal [] test = [0.25M, 0.5M, 0.125M , 0.125M]; //(start)-(end) //(0,5) - (0,5+ 0,25) //(0,5 + 0,25) - (0,5 + 0,25 + 0,125) //(0,5 + 0,25 + 0,125) - (0,5 + 0,25 + 0,125 + 0,1) //0.5 0 //0.25 1 //0-1 //0.5 0.25 0.125 0.125 //0 - 0.5 //unrare //0.5 - 0.75 //rare //0.75 - 0.875 //epic //0.875 - 1 //legend test = test.OrderByDescending(it => it).ToArray(); foreach (var @decimal in test) { Console.WriteLine(@decimal); } Random random = new Random(); decimal number = Convert.ToDecimal(Math.Round(random.NextDouble(),2)); Console.WriteLine($"Random number: {number}"); decimal startRange = 0; decimal endRange = test[0]; if(number >= startRange && number <= endRange) Console.WriteLine(true); for (int i = 1; i < test.Length; i++) { startRange = endRange; endRange = startRange + test[i]; if (number >= startRange && number <= endRange) { Console.WriteLine($"{startRange} - {endRange} {true}"); break; } }