Loops/For with a specified step

From Rosetta Code
Revision as of 18:16, 10 July 2009 by rosettacode>Glennj (Created page with '{{task|Iteration}} Demonstrate a for loop where the step value is greater than one. =={{header|Ruby}}== <lang ruby>2.step(8,2) {|n| print "#{n}, "} puts "who do we appreciate?"<…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Loops/For with a specified step
You are encouraged to solve this task according to the task description, using any language you may know.

Demonstrate a for loop where the step value is greater than one.

Ruby

<lang ruby>2.step(8,2) {|n| print "#{n}, "} puts "who do we appreciate?"</lang> Output

2, 4, 6, 8, who do we appreciate?