Write an application that computes all of the amicable

Assignment Help Basic Computer Science
Reference no: EM13856392

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.

Reference no: EM13856392

Questions Cloud

How will dns be accessed by the lsdg systems : How will systems receive IP addresses. Explain. How will DNS be accessed by the LSDG systems. Explain. Explain how files on the network may be accessed by LSDG.
Challenges for the improvement of the device : Consider that you are a senior consulting engineer and that you need to explain the topic in a written report to your customer, who is the managing director of a large company, and a commerce or law graduate.
What was the original price of the boat : His bank charged 6% per year compounded monthly and his monthly payments were $400. What was the original price of the boat?
Write about is criminal profiling : The topic you will write about is criminal profiling, Each student should select one item or subject of their choice from the forensic materials covered in this week's class materials, including lectures and/or reading assignment, and write a 1200..
Write an application that computes all of the amicable : 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.
Write a javascript program to make change : Write a JavaScript program to make change. You should use prompt() to read a string and parseInt() to convert the string into an integer number of cents (i.e. fractions of a dollar). Your program should write to the document how to deliver that nu..
Analyze the recidivism rates for sex crimes : Analyze the recidivism rates for sex crimes
Explain and clarify items shown on the financial statements : The purpose of footnotes is to explain and clarify items shown on the financial statements. Please list the number and name of each of the footnotes, as well as the page the footnote appears.
Analyze techniques for requirements determination : The specific course learning outcomes associated with this assignment are. Analyze techniques for requirements determination, collection, and organization

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd