Protected void CheckNumberIsStrongOrNot()
{
int
sof=0,n,dn,ctr,prod,rem;
n = Convert.ToInt32(txtStrong.Text);
dn=n;
while(n!=0)
{
prod=1;
ctr=1;
rem=n%10;
while(ctr<=rem)
{
prod=prod*ctr;
ctr=ctr+1;
}
sof=sof+prod;
n=n/10;
}
if(sof==dn)
{
MessageBox.Show("The number entered is strong number");
}
else
{
MessageBox.Show("The number entered is not a strong number");
}
}
No comments :
Post a Comment