Program for Factorial in Java

Here you will get program for factorial in java. We can find factorial of any number by multiplying it with all the numbers below it. For example, factorial of 4 is 4*3*2*1 = 24. Program for Factorial in Java   Output Enter a number: 6 Factorial = 720

Java program to swap two numbers

class Swap { public static void main(String…s) { int a,b,temp; a=Integer.parseInt(s[0]); b=Integer.parseInt(s[1]); System.out.println(“nBefore Swap:n”+”a=”+a+”tb=”+b); temp=a; a=b; b=temp; System.out.println(“nAfter Swap:n”+”a=”+a+”tb=”+b); } }

Program for Prime Number in Java

Here you will get program for prime number in java. A number is prime if it is divisible by 1 or itself. For example 2, 3, 5, etc are prime numbers while 4, 6, 8, etc are not prime. Program for Prime Number in Java   Output