#!/usr/bin/env ruby # find all divisors for a given number # usage example: # divisors 2 3 4 ARGV.each do |n| n = n.to_i print n.to_s + " " # show input at the start of line x = [] # array # loopines (1..n/2).each do |l| # brute force divison to half of the number x << l if n.to_f % l == 0 end # just add the number itself to the array x << n # results print x if x.length == 2 print " prime" else print " " + x.length.to_s end print "\n" # new line end