Write a function that takes two positive integers which define the values of a range. The function calculates and prints the ratio of the sum of even numbers to the sum of all the numbers in the range. input: Positive integers ‘start’ and ‘end’
Write a function that takes two positive integers which define the values of a
range. The function calculates and prints the ratio of the sum of even numbers to
the sum of all the numbers in the range.
input:
Positive integers ‘start’ and ‘end’
Output:
Ratio of sum of even numbers to the sum of all the numbers in the range defined by the numbers ‘start’ and ‘end’
Explaination:
Let’s say we have the values of ‘start’ and ‘end’ as 2 and 10 respectively. So, numbers between 2 and 10
are 2 , 3, 4 , 5 , 6 , 7, 8, 9 , 10
The sum of even numbesr in the given range is : 2 + 4 + 6 + 8 + 10 = 30
Total sum of all the numbers is 54
Ratio of the sum of even numbers to the sum of all the numbers in this range is 30/54 = 0.555 Hint: An even
number divided by 2 leaves a remainder 0.
7 years ago
5
Purchase the answer to view it

- Programratio.docx
- microbilogy 8
- Only Prof. Xavier
- Invest
- BUS 670 Week 2 Elements Of an Employment Contract
- BUS 599 Week 4 Assignment HRM Issues Diversification Strategies Case Nucor Corporation
- Provide one historical example of each goal/purpose. With which do you agree the most and why?
- control methods used by modern organizations
- Reverse Inventory Management & Financial Implications DB-5 Deliverable Length: See assignment details
- ACC 220 Week 5 DQ 1
- Essay