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

  • Home
  • SEARCH
  • 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 7010205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:57:40+00:00 2026-05-27T21:57:40+00:00

In Project Euler’s problem 9, I encounter a problem: infinite loops. Here is my

  • 0

In Project Euler’s problem 9, I encounter a problem: infinite loops.

Here is my code:

#include <iostream>
#include <cmath>

bool isPythagorean(int a, int b, int c);

int main(){
        int a;
        int aa;
        int b;
        int bb;
        int c;

        for(a = 0; a <= 1000; a++){             /*a loop*/
                aa = a;
                for(b = aa; b <= 1000; b++){     /*b loop*/
                        bb = b;
                        for(c = bb; c <= 1000; c++){
                                if(isPythagorean(a,b,c)){
                                        if(a + b + c == 1000){
                                                std::cout << (a * b) * c;
                                                return 0;
                                        }
                                else
                                        continue;
                                }





                }




        }

        return 1;
}
bool isPythagorean(int a, int b, int c){
        int Pa = (int) pow(a, 2);
        int Pb = (int) pow(b, 2);
        int Pc = (int) pow(c, 2);
        if(a < b && b < c){
                        if(Pa + Pb == Pc)
                                return true;
                        else
                                return false;    
        }

        else
                return false;
}

Courtesy of everyone who has helped the idiot writing this, the code has been changed, but the error still stands:

When the code is run, nothing is output to the terminal. Could anyone kindly tell me what is going wrong here?

(I am such an idiot; My thanks go to everyone that is even looking at this.)

Thank you, istrandjev for noticing a whole host of bad pieces of code.

Thank you, Blastfurnace for noticing that stupid error.

  • 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-27T21:57:41+00:00Added an answer on May 27, 2026 at 9:57 pm

    I don’t get much of the logic you are trying to apply. What is a%1==0&&b%1==0&c%1==0 checking? You can simply write it if(true), you know. Also when is the cycle supposed to end? How is a triplet supposed to be Pythagorean if one of the conditions is a > c and then you want to have a*a + b*b == c*c?

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

Sidebar

Related Questions

I have this code written for a Project Euler problem in c++: int sum
I'm having trouble with Project Euler's problem 12. My code is correctly generating the
I'm working on Project Euler Problem 14. Here's my solution. import Data.List collatzLength ::
Here is how Project Euler Problem #76 sounds like: How many different ways can
This is a Project Euler problem. If you don't want to see candidate solutions
I'm trying to work through Project Euler and I'm hitting a barrier on problem
Some of you may recognize this as Project Euler's problem number 11. The one
I'm playing around with Project Euler's Problem 220 , and I'm a little confused
NOTE: This is a solution for Project Euler Problem 14 . If you still
Project Euler has a paging file problem (though it's disguised in other words). I

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.