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...


program to check if a number is "perfect number".



program to check if a number is "perfect number"...

Answer / athresh

public boolean isPerfect(int number)
{
int i = sumFactors(number);
if (i == number)
{
return true;
}
else
return false;
}


public int sumFactors(int number)
{
int factor = 0, sum = 0;
for (int i = 1; i < number; i++){
if (!(number % i)){
factor = i;
sum += factor;
}
}
return sum;
}

Is This Answer Correct ?    13 Yes 13 No

Post New Answer

More C Sharp Code Interview Questions

how to change password in .net with c # with ado.net and also SQL server 2008 change password

1 Answers  


How to pass multiple rows from one gridview to another gridview after clicking the checkbox.

1 Answers   Satyam,


Code for Reading and writing from a file?

0 Answers   IBM, Xoriant,


Code for Working with Files under a Directory?

1 Answers  


Code for Reading and writing from a file in c#?

1 Answers  


program to reverse the order of words in a string.

2 Answers   Mind Tree,


program to check if a number is "perfect number".

1 Answers   Mind Tree, SoftSol,


program for straight line(y=mx+c)

0 Answers   Mind Tree,


program for addition of fraction(M/N + P/Q = Y/Z)

1 Answers   Mind Tree,


Write a program. there are 1..n numbers placed in an array in random fashion with one integer missing. find the missing number.

1 Answers   Infosys, Mind Tree,


Code for Searching for Multiple Matches with the MatchCollection Class?

0 Answers   TCS,


How to add a value from textBox over an existing certain column in SQL Server

0 Answers  


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)