Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help in Python! Prob. 5 Thunder-split numbers: An integer n is called a thunder-split number if it can be split into two numbers, and

Please help in Python!

image text in transcribed

Prob. 5 Thunder-split numbers: An integer n is called a thunder-split number if it can be split into two numbers, and the square of the sum of these two numbers equals to the original number n The story behind the term thunder-split is this: An Indian mathematician travelling in a foreign land encountered a big thunder-storm, during which he saw a stone monument being struck and split in half by the thunder. Interestingly, the stone originally had 3025 on it, after the thunder-split, one part contained 30 and the other contained 25. The mathematician quickly realized that (30 + 25)2- 552- 3025, thus he named any integer having this property as a thunder-split number. Besides 3025, we see that 9801 is also a thunder-split number because it can be split into 98 and 01, and (9801992 -9801. Similarly, 81 is such a number since (81)292 81; 100 is such as number since (10 +0)2 100, and 60481729 is such a number since (60481729)2 77772-60481729 Write a function tsplit.nums (m), where m > 10, that returns all the thunder-split numbers within the range [10, m]. Use your code to find all the thunder-split numbers in 10, 10, print all of them out using the following format (notice the empty spaces used to make the numbers align in place): 81 can be thunder-split as (8 100 can be thunder-split as (10 2025 can be thunder-split as (20 3025 can be thunder-split as (30 *2 2 + 25 2 3 + 25 2 5 6 7 8 4941729 can be thunder-split as (494+ 1729 2 7441984 can be thunder-split as (744+1984 2 9 25502500 can be thunder-split as (2550 2500*2 99980001 can be thunder-split as (9998 +0001 2 10 Note: the above lines are part of the results for [10, 10], for this problem you only need to print out all thunder-split numbers in [10, 10] (because when m 10 it will take very long to compute if you do not find a more efficient way) Bonus 10 points: Find a way to speed up your code so that you can compute all the thunder- split numbers in [10, 109]. In this case, your results would cover all of the numbers listed above. If done right, your code should take less than 2 seconds to run and finish (even on an aged laptop) Prob. 5 Thunder-split numbers: An integer n is called a thunder-split number if it can be split into two numbers, and the square of the sum of these two numbers equals to the original number n The story behind the term thunder-split is this: An Indian mathematician travelling in a foreign land encountered a big thunder-storm, during which he saw a stone monument being struck and split in half by the thunder. Interestingly, the stone originally had 3025 on it, after the thunder-split, one part contained 30 and the other contained 25. The mathematician quickly realized that (30 + 25)2- 552- 3025, thus he named any integer having this property as a thunder-split number. Besides 3025, we see that 9801 is also a thunder-split number because it can be split into 98 and 01, and (9801992 -9801. Similarly, 81 is such a number since (81)292 81; 100 is such as number since (10 +0)2 100, and 60481729 is such a number since (60481729)2 77772-60481729 Write a function tsplit.nums (m), where m > 10, that returns all the thunder-split numbers within the range [10, m]. Use your code to find all the thunder-split numbers in 10, 10, print all of them out using the following format (notice the empty spaces used to make the numbers align in place): 81 can be thunder-split as (8 100 can be thunder-split as (10 2025 can be thunder-split as (20 3025 can be thunder-split as (30 *2 2 + 25 2 3 + 25 2 5 6 7 8 4941729 can be thunder-split as (494+ 1729 2 7441984 can be thunder-split as (744+1984 2 9 25502500 can be thunder-split as (2550 2500*2 99980001 can be thunder-split as (9998 +0001 2 10 Note: the above lines are part of the results for [10, 10], for this problem you only need to print out all thunder-split numbers in [10, 10] (because when m 10 it will take very long to compute if you do not find a more efficient way) Bonus 10 points: Find a way to speed up your code so that you can compute all the thunder- split numbers in [10, 109]. In this case, your results would cover all of the numbers listed above. If done right, your code should take less than 2 seconds to run and finish (even on an aged laptop)

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

=+How might you explain this phenomenon?

Answered: 1 week ago