Computer Science, asked by cutekhushicute7649, 1 year ago

C program to find if a number is a sum of two squares

Answers

Answered by navibrohackernp4zz24
0
i dont know the exact answer but the below given program will be helpful for you
// A brute force approach based implementation// to find if a number can be written as sum// of two squares.#include <bits/stdc++.h>using namespace std; // function to check if there exist two// numbers sum of whose squares is n.bool sumSquare(int n){    for (long i = 1; i * i <= n; i++)        for (long j = 1; j * j <= n; j++)            if (i * i + j * j == n) {                cout << i << "^2 + "                     << j << "^2" << endl;                return true;            }    return false;} // driver Programint main(){    int n = 25;    if (sumSquare(n))        cout << "Yes";    else        cout << "No";}
Similar questions