The number 5 is important in number theory because 5 is the length of the hypotenuse of the smallest integer-sided right triangle. A number is called good if the sum of its digits is divisible by 5. You are given an integer [Math Processing Error]. Your task is to find the [Math Processing Error] good number that is greater than a provided number [Math Processing Error] modulo [Math Processing Error] For example, 235 is a good number since the sum of all digits is 10 that is divisible by 5 whereas 231 is not a good number.
Answers
Answered by
17
Explanation:
Pythagoras Theorem applied to triangles with whole-number sides patterns and properties of these integer sided right angled triangles. 10.1.1 Squares with more than 5 Pythagorean Triangles.
Answered by
0
#include<iostream>
using namespace std;
int good_no(int n)
{
int s = 0;
while(n!=0)
{
s = s+(n%10);
n = n/10;
}
if(s%5==0)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
int n;
cout<<"Enter a number : ";
cin>>n;
if(good_no(n)==1)
{
cout<<n<<" is a good number.";
}
else
{
cout<<n<<" is not a good number."<<endl;
cout<<"Good number higher than "<<n<<" is ";
while(good_no(n)!=1)
{
n++;
}
cout<<n;
}
return 0;
}
Attachments:
Similar questions