Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3238316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:50:23+00:00 2026-05-17T17:50:23+00:00

i need a quick hint regarding the following exercise question: Write a program that

  • 0

i need a quick hint regarding the following exercise question:

Write a program that generates all Pythagorean triples whose small sides are no larger than n. Try it with n <= 200.

what is “no longer than n” all about ??

exercise source: Java by Dissection (Ira Pohl and Charlie McDowell)

note: i found what looks to be a very good post on pythagorean triples but i won’t read it yet as it might spoil my attempt to solve this myself….

EDIT

if n is length of the small side a and we say: n is 5;
then i need to check all triples with a=1,a=2,a=3,a=4,a=5
and find the cases that are Pythagorean triples

what is this extra condition good for?

EDIT 2

maybe i’ll get closer if i show you a practical piece…so here is a short piece of (python) code that returns a few triples. I’ve set the upper limit for the outer loop to 20 (for now i can’t see any other use for ‘n’) to keep it managable for the post.

import math
for b in range(20):
    for a in range(1, b):
        c = math.sqrt( a * a + b * b)
        if c % 1 == 0:
            print (a, b, int(c))

this returns

(3, 4, 5)
(6, 8, 10)
(5, 12, 13)
(9, 12, 15)
(8, 15, 17)
(12, 16, 20)

is that the desired output? what is the step that i’m missing?

thanks in advance

Baba

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:50:23+00:00Added an answer on May 17, 2026 at 5:50 pm

    Pythagorean triples are the integer sides of a right triangle. The small sides of the triangle are the sides that form the right angle (meaning not the hypotenuse).

    no larger than n means you are given an integer n and must generate all possible triples of integers a b c such that a <= n, b <= n and a^2 + b^2 = c^2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are your best usability testing tips? I need quick & cheap.
I need a quick algorithm to select 5 random elements from a generic list.
I need a quick easy way to get a string from a file in
I need a quick yes/no answer on this... Is it possible to get a
I need a quick way to find out if a given port is open
I need a quick no for DELETE/UPDATE/INSERT, since 3p reporting tool allows users to
What do the result codes in SVN mean? I need a quick reference.
I need a very quick fix in a mod_rewrite expression for drupal we have
I need to create a quick-n-dirty knob control in Visual Basic 2005 Express, the
I need to do some quick-and-dirty Perl GUI building. I can't afford a Komodo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.