Problem 6

24 comments on “Problem 6”


  • vivek

    #include
    int main(){
    int N;
    scanf(“%d”,&N);
    int a,b,c=0,m=2;
    while(cN){
    break;
    }
    printf(“%d %d %d\n”,a,b,c);
    m++;
    }
    }


  • Sandeep

    import java.util.HashSet; public class PythrogorousTriplets {
    public static void main(String[] args) {
    printTriplets(20);
    }
    static void printTriplets(int limit) {
    HashSet hashSet = new HashSet();
    for (int i = 1; i <= limit; i++) {
    hashSet.add(i*i);
    }
    for (int i = 1; i <= limit; i++) {
    for (int j = 1; j <= limit; j++) {
    int val = (i*i)+(j*j);
    if(hashSet.contains(val)) {
    System.out.print(i+" "+j+" "+" "+(int)(Math.sqrt((int)val)));
    System.out.println();
    }
    }
    } }
    }


  • Vkjha

    n=int(input())
    a=[0]
    for i in range(1,n+1):
    a.append(i*i)

    for j in range(1,n+1):
    for k in range(1,n+1):
    d=j*j+ k*k
    for l in range(0,n):
    if a[l]==d:
    print(j,k,l)
    a[l]=0


  • GAURAV

    #include
    #include
    #include
    using namespace std;

    int main()
    {
    mapmp;
    for(int i=1;i<=20;i++)
    mp[i*i]=1;
    for(int i=1;i<mp.size();i++){
    for(int j=i+1;j<mp.size();j++){
    if(mp.find(i*i+j*j)!=mp.end()){
    int k=sqrt(i*i+j*j);
    cout<<i<<" "<<j<<" "<<k<<endl;}
    }}

    return 0;
    }


  • hanish

    def pyt(l):
    if l>0:
    for a in range(l-1):
    for b in range(l):
    for c in range(l+1):
    if a*a+b*b=c*c:
    print(a,b,c)
    def(20)


  • shushank

    import math
    n=int(input())
    for i in range(1,n):
    c1=i
    for j in range(i+1,n+1):
    c2=j
    d=c1**2+c2**2
    d1=math.sqrt(d)
    if int(d1)==d1:
    print(c1,c2,int(d1))


  • Debanjan

    import math
    def Pythagoran_Triplet(l):
    i=3
    while(i<l):
    j=i+1
    while j<l:
    c=math.sqrt(i**2+j**2)
    if c.is_integer():
    print(i,j,int (c))
    else:
    j+=1
    continue
    j+=1
    i+=1
    L=int(input("Enter Limit"))


  • Raman

    // Online C compiler to run C program online
    #include

    int main() {
    int m=1,n=1;
    int a,b,c;
    for(n=1;n<=20;n++){
    for(m=1;m<=20;m++){
    a=(m*m)-(n*n);
    b=2*m*n;
    c=(m*m)+(n*n);
    if(c0){
    printf(“%d %d %d”,a,b,c);
    printf(“\n”);
    }
    }
    }

    return 0;
    }


  • Raman

    // Online C compiler to run C program online
    #include

    int main() {
    int m=1,n=1;
    int a,b,c;
    for(n=1;n<=20;n++){
    for(m=1;m<=20;m++){
    a=(m*m)-(n*n);
    b=2*m*n;
    c=(m*m)+(n*n);
    if(c0){
    printf(“%d %d %d”,a,b,c);
    printf(“\n”);
    }
    }
    }

    return 0;
    }