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

  Two-way set associative with 32 kb capacity and 64 byte

1. Assume a two-way set associative with 32 KB capacity and 64 bytes blocks. a. How many bits are needed to represent the index size?

  Write a java for file processing according to rules

The file is read into memory, all of it in one buffer, and the buffer is reversed, then the file is overwritten. For simplicity, we may assume that the maximum size of the file is 200000 bytes. If no file was selected an error message is displayed..

  Decide which of the following identifier forms

Decide which of the following identifier forms is most readable, and then support the decision. SumOfSales Sum_of_sales SUMOFSALES

  Create a short email message on the importance of a college

Email the message to your instructor using the email address provided by them and carbon copy an alternate email address (you can use your own address).

  Identify three error types you will look for

Explain your approach for verifying that the spreadsheet does not contain errors. Identify three error types you will look for. Identify 3R's to look for, and why is this important? Describe the elements of a professionally formatted datasheet.

  Describe two or three techniques that you would propose

Relate what you believe to be the most common biases among yourself and your colleagues on typical projects within your organization, and discuss the associated impact to the risk identification and risk analysis processes.

  Create a program that will calculate the daily pay

Using a loop, create a program that will calculate the daily pay and total pay assuming you get paid 1 penny the first day and then double every day after the first day. Display these numbers in a listbox. Use a inputbox to ask the user how many d..

  Management prefers to get the server with the os

Management prefers to get the server with the OS already installed and wants to keep management tasks as simple as possible. which windows server 2012/r2 edition do you recommend? explain your answer please ?

  Rewrite code especially for each type of hardware platform

Portability is the ability of software to move easily from one hardware platform to another. UNIX was the first portable operating system, allowing programs to compile on multiple hardware platforms without the need for the programmer to rewrite code..

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Assignment on polymorphism

Assignment on Polymorphism, How to design and define interface, How to implement methods declared in interface

  Create a details element that displays the summary

Write an HTML5 element (or elements) to accomplish each of the following tasks: a. Students were asked to rate the food in the cafeteria on a scale of 1 to 10.

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