Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 2.7 16 = 21 Background: In number theory, a triangle number is an integer defined by the formula Inspiration for its name can be

image text in transcribed python 2.7

16 = 21 Background: In number theory, a triangle number is an integer defined by the formula Inspiration for its name can be found in the figure above. The first few triangle numbers are 1, 3, 6, 10, 15, 21, 28. 36, and 4.5 In number theory, a square number is a square of an integer. For example, 0, 1, 4 and 9 are square numbers (020 12-1, 224, and 329) Every so often a triangular number may also be a square number. An integer that is both triangle and square is called a square triangle number. The first two square triangle numbers are 1 and 36 Your job: Write a program which prints the first 11 square triangle numbers. If we let Ni be the ith square triangle number, then your code is going to find , , N11 (we already know M = 1, N2-36). (HINT: Compute the triangle numbers recursively as discussed in class, otherwise your code will be too slow and may never finish!). Finally, numerically check the theoretical number theory result that 4 Verify this property by having your program output the raos the numerical value of V2), as well as the error: For full credit, your program must compute the triangular number according to the summation formula Eq. (4) and not some other (simplified) formula you find on the internet (the code must use a loop) Save your program as TriangleNumbers.py 16 = 21 Background: In number theory, a triangle number is an integer defined by the formula Inspiration for its name can be found in the figure above. The first few triangle numbers are 1, 3, 6, 10, 15, 21, 28. 36, and 4.5 In number theory, a square number is a square of an integer. For example, 0, 1, 4 and 9 are square numbers (020 12-1, 224, and 329) Every so often a triangular number may also be a square number. An integer that is both triangle and square is called a square triangle number. The first two square triangle numbers are 1 and 36 Your job: Write a program which prints the first 11 square triangle numbers. If we let Ni be the ith square triangle number, then your code is going to find , , N11 (we already know M = 1, N2-36). (HINT: Compute the triangle numbers recursively as discussed in class, otherwise your code will be too slow and may never finish!). Finally, numerically check the theoretical number theory result that 4 Verify this property by having your program output the raos the numerical value of V2), as well as the error: For full credit, your program must compute the triangular number according to the summation formula Eq. (4) and not some other (simplified) formula you find on the internet (the code must use a loop) Save your program as TriangleNumbers.py

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

Students also viewed these Databases questions

Question

Identify what the Capital Asset Pricing Model calculates.

Answered: 1 week ago