Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

how create loop to skip every 4th value

Avatar

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Validate 10
Level 2
eugzl
Level 2

Likes

5 likes

Total Posts

171 posts

Correct Reply

5 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 1
View profile
eugzl
Level 2

09-03-2018

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 2
ulibaehr
Level 2

Likes

2 likes

Total Posts

71 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Validate 1
Level 2
ulibaehr
Level 2

Likes

2 likes

Total Posts

71 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Boost 1
Affirm 3
Affirm 1
View profile
ulibaehr
Level 2

15-03-2018

try the modulo-operator:

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

Answers (0)