PALINDROMES ;
> A like as ,string is called a palindrome string if the reverse of that string is the same as the original string.
> For example, radar, level, etc.
> Similarly, a number that is equal to the reverse of that same number is called a palindrome number.
> For example, 3553, 12321, etc.
USING WHILE LOOP ;
Public class palindrome
{
Public static void main(String[]args)
{
Int n = 1211;
Int p, sum = 0;
Int Temp = n ;
While (n>0)
{
P = n%10;
Sum = ( sum * 10)+P;
n = n/10;
}
System.out.println(“value is :: “+sum);
If (temp == sum)
{
System.out.println (“value is true”);
}
Else
{
System.out.println(“value is false”);
}
}
}
FACTORIAL ;
> Factorial of a positive integer n is the product of all values from n to 1.
> For example, the factorial of 3 is (3 * 2 * 1 = 6)
PROGRAM ;
Public class Fact
{
Public static void main (String[]args)
{
Fact fact = new Fact ();
fact (30);
}
Static void fact (int n)
{
Int fact = 1;
For (int i = 1; i<=n ; i++)
{
fact = fact * i ;
}
System.out.println(“Fact value is ::”+ fact);
}
}
PRIME NUMBER ;
> Prime number is a number that is greater than 1 and divided by 1 or itself only.
> In other words, prime numbers can’t be divided by other numbers than itself or 1.
> For example 2, 3, 5, 7, 11, 13, 17……are the prime numbers.
PROGRAM ;
Public class prime
{
Public static void main (String[]agrs)
{
Prime value = new prime ();
Value.primeNum(50) ;
}
Void primeNum ( int p )
{
Int count = 0 ;
For ( int s = 1 ; s<=p ; s++) ;
{
Int t = p%s ;
If (t == 0)
{
t ++ ;
Count = count + t ;
}
}
If ( count == 1)
{
System.out.println(“there is a prime”);
}
else
{
System.out.println(“there is a non prime”);
}
}
WHILE AND FOR LOOP ;

> It is normally used when the number of iterations is unknown.
> Initialization is always outside the loop.
> While is also entry controlled loop.
> while ( condition ) { statement(s); }
FOR LOOP ;
> It is used when initialization and increment is simple.
> Initialization may be either in loop statement or outside the loop.
> For is entry controlled loop.
> for ( init ; condition ; iteration ) { statement(s); }
