Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

urgent (python) Problem 1. Largest power In this problem, you are not allowed to use the Math module and any other module. a) Largest power

urgent (python) image text in transcribed
image text in transcribed
Problem 1. Largest power In this problem, you are not allowed to use the Math module and any other module. a) Largest power of 2 dividing n. Implement the function largestPowerOf2 Dividing(n), which given a positive integer n, finds and returns the largest power of 2 which divides n. That is given n, largestPowerOf2Dividing(n) returns the largest i such that 2 divides n. Assume n is a positive integer. Test program Output print("a)") a) print(largestPowerOf2Dividing(1)) 0 print(largestPowerOf2Dividing(2)) 1 print(largestPowerOf2Dividing(3)) 0 print(largestPowerOf2Dividing(4)) 2 print(largestPowerOf2Dividing(5)) 0 print(largestPowerOf2Dividing(20)) 2 print(largestPowerOf2Dividing(48)) # 48 = 3 (2) 4 b) Largest power dividing n. Implement the function largest PowerDividing(n), which given a positive integer n, finds and returns the largest power of an integer greater than I which divides n. That is given n, largest Power Dividing(n) returns the largest i such that x' divides n, for some integer x > 1. For instance: largest PowerDividing(50) - 2 since 50 -2x5, and largest PowerDividing(362063535) = 6 since 362063535 - 3x5x17". Assume n is a positive integer. Test program Output print("b)") b) print(largestPowerDividing(1) print(largestPowerDividing(2)) 1 print(largestPowerDividing(3)) 1 print(largestPowerDividing(4)) 2 print(largestPowerDividing(5)) print(largestPower Dividing(9)) 2 print(largestPowerDividing(25)) 2 print(largestPower Dividing(50)) print(largestPower Dividing(162)) #162 - 2*(3**4) 4 print(largestPowerDividing(362063531)) 1 print(largestPowerDividing(362063535)) 1 NN

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

Step: 3

blur-text-image

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

Students also viewed these Databases questions

Question

LO1 Summarize the organizations strategic planning process.

Answered: 1 week ago