Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

if n = 10000, the answer should look like this, but the number of steps is wrong for the following code, the following code gets

image text in transcribed

if n = 10000, the answer should look like this, but the number of steps is wrong for the following code, the following code gets 10000 steps, while it should be 56971 steps. Can you please help to get the right code? Thank you.

image text in transcribed

image text in transcribed

Consider the number 220 Find the sum of factors, except the number itself (also called proper divisors) 220=1+2+4+5+10+11+20+44+55+110=284 Now find the sum of factors for 284 284=1+2+4+71+142=220 220 and 284 are called the Pairs Write a Python program that 1. prints all the pairs 2. number of steps took to compute pairs \#\# s= Solution(n,a) \#\#All action happens here \#\# a[0]= How many pairs are there in n. Use_increment_number_of_pairs to fill \#\# a[1] = num_steps . Use_increment_steps class Solution: def_init_(self,n:'int',a:'list of size 2 '): self._n n=n \#\# s = Solution(n,a) \#AAll action happens here \#\# a[0]= How many pairs are there in n. Use increment_number_of_pairs to fill \#\# a[1] = num_steps Use _increment_steps self._list =a \#\# You can have any number of data structures here \#\# Nothing can be changed below self._alg() def_increment_steps(self)->'none': self._list[1] = self._list[1]+ 1 def_increment_number_of_pairs(self)->"int": self._list [0]= self._list [0]+1 return (self._list[0]) \#\#You can have any number of private variables and functions def_alg(self): print("Code") print("Use as many small functions as possible") \# Implement your code here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Describe the typical terrorist cell.

Answered: 1 week ago