number as square of two integers

Given an integer n decide if it is possible to represent it as a sum of two squares of integers.

Comments

  1. cin>>X;
    i=sqrt(X);
    j=sqrt(X-i*i);
    while(i>=0 && i>=j)
    {
    if((i*i)+(j*j)==X)
    {count = 1;break;}
    i--;
    j=sqrt(X-i*i);
    }
    if(count == 1)
    cout<<"Yes";
    else cout<<"No";

    ReplyDelete

Post a Comment

Popular posts from this blog