Populate an array in ruby with 7n +1 -


how make following array programatically in ruby (1.9).

it follows pattern 7n + 1 , i'd contain 24 numbers.

arr = ["8","15","22","29","36","43","50","57","64","71" ] 

use collect , apply to_s on result:

(1..24).collect{|n| (n*7 + 1).to_s} 

edit: sorry forgot convert numbers strings. code edited now.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -