Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to check whether a given integer is a strong
number or not?
[Hint:
145=1!+4!+5!
=1+24+120
=145]

Answer Posted / abhijit

using System;
using System.Collections.Generic;
using System.Text;

namespace Practice
{
class Program
{
public static int fact(int r)
{
if (r == 0 || r == 1)
return 1;
else
return (r * fact(r - 1));
}
static void Main(string[] args)
{
args = new string[1];
args[0] = Console.ReadLine();

int n, tmp, rem, sum = 0;

int ii = fact(5);
n = Convert.ToInt32(args[0]);
tmp = n;
int jj=0;
while (n != 0)
{
rem = n % 10;

jj=fact(rem);
sum = sum + jj;
n = n / 10;
}

if (tmp == sum)
Console.WriteLine(tmp + "is a strong number");
else
Console.WriteLine(tmp + " is not a strong number");
Console.ReadLine();
}


}
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do the functions atoi(), itoa() and gcvt() do?

1137


What is difference between union and structure in c?

1070


What is action and transformation in spark?

1082


What is the difference between declaring a variable and defining a variable?

1185


What is the right type to use for boolean values in c? Is there a standard type?

967


Is that possible to add pointers to each other?

1319


What is operator promotion?

1011


What are types of preprocessor in c?

1015


How do you print an address?

1212


Explain the priority queues?

1032


What are the 32 keywords in c?

1042


What is variable and explain rules to declare variable in c?

1017


What are the __date__ and __time__ preprocessor commands?

1040


What is the most efficient way to store flag values?

1126


What are global variables?

1117