Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
 Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM

 Categories  >>  Code Snippets  >>  Programming Code  >>  Dot Net Code  >>  C Sharp Code

 ASP.NET Code Interview Questions VB.NET Code Interview Questions C Sharp Code Interview Questions ADO.NET Code Interview Questions
Question
`program to check if a number is "perfect number".`
Question Submitted By :: Lakshmipriya
I also faced this Question!!     Rank Answer Posted By

Re: program to check if a number is "perfect number".
# 1
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 ? 9 Yes 10 No
Athresh

  Question Asked @ Answers Other C Sharp Code Interview Questions program for string reverse(eg:- i am boy -> boy am i) Mind-Tree 8 How to Create a Treeview Menu in ASP.NET with C#? 1 Write a program to input an integer and - display the reverse - display the sum of each digit - should include logic that considers the input number as any number of digits long Mind-Tree 2 how to change password in .net with c # with ado.net and also SQL server 2008 change password 1 Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C# 1 program to reverse the order of words in a string. Mind-Tree 2 "c sharp" code for factorial using static variables 8 Coding for using Nullable Types in C#? 1 How to Create Files by Using the FileInfo Class? 1 How to pass multiple rows from one gridview to another gridview after clicking the checkbox. Satyam 1 How to use ASP.NET 2.0's TreeView to Display Hierarchical Data? 1 c# coding for a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors not using the Big-integer and Exponential Function's. TCS 1 For more C Sharp Code Interview Questions Click Here