Expand my Community achievements bar.

SOLVED

how create loop to skip every 4th value

Avatar

Level 5

Hi All.

I would like to create loop to skip each fourth number and multiply result by 7. What I mean. If a regular sequence is:

0, 1, 2, 3 ,4 ,5, 6, 7, 8, 9, 10, 11, 12 and so on.

I would like to get sequence:

0, 1, 2 ,4, 5, 6, 8, 9, 10, 12, 13, 14 and so on. In that sequence the numbers 3, 7, 11 are skipped.

And multiply number from sequence by 7.

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 4

try the modulo-operator:

if (iNumber % 4 == 3) { /* then skip */ } else { /* print */ }

View solution in original post

1 Reply

Avatar

Correct answer by
Level 4

try the modulo-operator:

if (iNumber % 4 == 3) { /* then skip */ } else { /* print */ }