The code should be written in ruby and answers are


The code should be written in Ruby and answers are displayed in the command prompt. Write an application that computes all of the amicable numbers less than the upper bound that is read in using a gets statement. (Use STDIN.gets if you want to be more complete.) The computations will be done in the main method output will be shown by printing directly to the command line with print (or STDOUT.print if you want to be more complete.) The factors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110; 1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 55 + 110 = 284. The factors of 284 are 1, 2, 4, 71, 142; 1 + 2 + 4 + 71 + 142 = 220. Therefore, 220 and 284 a pair of amicable numbers. Change the string input read by STDIN.gets into an integer. Do not print any pair of perfect numbers in your output and do not print a pair of amicable numbers more than once. You can satisfy these requirements by only printing the numbers n and sum1 where n == sum2 && n < sum. Use the sum_factors method from the Example that computes the sum of all the factors of the value passed to it.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: The code should be written in ruby and answers are
Reference No:- TGS01136536

Now Priced at $35 (50% Discount)

Recommended (94%)

Rated (4.6/5)