4
Contributors
5
Replies
6
Views
11 Years
Discussion Span
Last Post by portege
0

Should work. I'm leaving to go home and won't both going through it.

#include <iostream>
#include <fstream>
using namespace std;
int main(){
int i=0,m=2,a,b,c,f=2;
while (i<1000){
a=2*m;
b=m*m-1;
c=m*m+1;
while (f<=a){
if (a%f!=0 and b%f!=0 and c%f!=0){
f++;}}
if (f=a+1){cout<<a<<", "<<b<<", "<<c;
i++;}}
system("pause");}
0

I just realized that that may not be what you wanted. Do you mean c^2<=100, c<1000, or the first 1000 triplets? :?:

0

That code wouldn't work at all anyway; the values of m, a, b, and c never change.

And it seems completely oblivious to triplets like 20,21,29.

0

You're right. I forgot about that. This should take everything into effect and list the first 1000 triplets. For some reason, it isn't working.

#include <iostream>
#include <fstream>
using namespace std;
int main(){
int a,b,c,d,i,m=2,n,nmax=1,count=0;
while (count<1000){
n=1;
while (n<nmax){
nmax=m-1;
i=2;
a=2*m*n;
b=m*m-n;
c=m*m+n;
while (i<a){
if (a%i==0 and b&i==0 and c&i==0){
cout<<"NO MATCH";}
else {i++;}}
if (i==a){
if (b%i==0 and c%i==0){cout<<"NO MATCH";}
else {cout<<a<<b<<c;count++;}}
n++;}
m++;}
system("pause");}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.