Question: Create an HTML document which links an external stylesheet and an external JavaScript file. That is the default setup in repl.it. The HTML file should

Create an HTML document which links an external stylesheet and an external JavaScript file. That is the default setup in repl.it. The HTML file should initially contain no visible content between the tags.

In pythagoras.js, prompt the user for a number on page-load. This number should be between 10 and 300 (inclusive). If the user enters something invalid (not a number or out of range), prompt them again. Then, usign JavaScript write the following table to the document:

a b c

The table body should contain all Pythagorean triples which lie between the numbers 1 and N, where N was the number the user gave earlier. A Pythagorean triple is a triple of positive integers a, b, and c that satisfies a2 + b2 = c2. The table should not contain duplicates. (3, 4, 5) and (4, 3, 5) are considered the same triple.

Hint: Use three nested loops to find all triples. For example, the following loop will generate all triples between 1 and 20 ((1, 1, 1), (1, 1, 2), (1, 1, 3), , (1, 2, 1), (1, 2, 2), (1, 2, 3), , (20, 20, 20)).

for (var i = 0; i < 20; i++)

for (var j = 0; j < 20; j++)

for (var k = 0; k < 20; k++)

// use triple (i, j, k)

You will need to modify these loops to avoid duplicates.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!