Skip to main content

Posts

Perfect number in java, program for perfect number in java

A perfect number is one where the sum of factors of a number (excluding the number itself) is equal to the number itself. EXAMPLE- We take 6. Factors of 6 are: 1,2,3 6 = 1 + 2 + 3 6 is a perfect number. Now we take 28 .Factors of 28 are: 1,2,4,7,14 28 = 1 + 2 + 4 + 7 + 14 28 is a perfect number. Perfect number in java language can be made by first applying a for loop starting from 1 to 1 less than that number and then with the help of if statement, checking if the number is divisible by that particular number which is currently stored in loop control variable.  Then after the loop terminates we will check whether the sum of factors of the number is equal to the number itself or not. If the statement returns true then appropriate statement prints. Here is the code for perfect number in two different formats firstly with the help of methods and secondly a very simple program using main method.

Java program for prime numbers

A prime number is the number which is is  divisible by itself and not by other numbers. A program to check prime number can be made by using for and while loop combination . This article contains java program for finding prime number ,write a java program for prime number between 1- 100 ,simple program to find prime factorial of a number in java. EXAMPLE 1 - program to check whether a number is prime number  or not. import java.util.*; public class pr { public static void main() { Scanner sc=new Scanner(System.in); System.out.println("enter number"); int num=sc.nextInt(); int d=0; for(int i=2;i<=num;i++) { if(num%i==0) d++; } if(d==0) System.out.println("it is a prime number"); else System.out.println("it is not a prime number"); } } Output enter number 23 it is a p...

Top 5 best survey sites for india

Hi everyone ,  We know that taking survey online is the best way to make a decent amount of money  and to be real you can easily make 500 to 800 rupees per month by taking survey for  half an hour a day. There are a lot of survey site online but hardly very few are legitimate and provide real money so in this article i am telling about top 5 survey site which are legit ,safe and you also get decent amount of survey So let's get started Remember survey amount depend upon your demographics. 1. The panel station This survey site is best for tier 2/tier 3 cities as they offer almost 4-5 surveys per days for tier2/ tier 3 cities in india .this panel is indian with its headquater in Bengaluru. Redemption - to get your money paid out you have to complete 3000 points which can completed easily in about a week.each survey will give you 300-1000 points. 10 point isequal to 1  rupees so you...