We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
//Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square#include<iostream>#include<math.h>usingnamespacestd;boolisPerfectSquare(longdoublex){// Find floating point value of// square root of x.longdoublesr=sqrt(x);// If square root is an integerreturn((sr-floor(sr))==0);}intmain(){unsignedlongintrange=0100,sum=0,rem=0,bsum=0,lo=0;cin>>range;unsignedlonginthold;for(inti=1;i<=range;i++){hold=i;while(hold>0){rem=hold%10;hold/=10;sum+=rem*rem;lo+=sum;sum=0;}if(isPerfectSquare(lo)){bsum+=i;}lo=0;}cout<<bsum;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square
You are viewing a single comment's thread. Return to all comments →
what's the error in it can anyone tell that...