void regular(int R[], int n)
{
if (n >
0)
{
int
index_2 = 0;
int
index_3 = 0;
int
index_5 = 0;
int
regular_2 = 2;
int
regular_3 = 3;
int
regular_5 = 5;
R[0] = 1;
for (int next_index = 1; next_index < n; ++next_index)
{
int next_regular
= min(regular_2, regular_3, regular_5); // O(0)
R[next_index] = next_regular;
if
(regular_2 == next_regular)
{
regular_2 = R[++index_2] * 2;
}
if
(regular_3 == next_regular)
{
regular_3 = R[++index_3] * 3;
}
if
(regular_5 == next_regular)
{
regular_5 = R[++index_5] * 5;
}
}
}
}
// if you like, you can replace index with
pointer for better performance.