## fibonacci series

``` mkjgvfhffdfdrdclass Fibonacci
{
public static void main ( String s [] )
{ int n2 =1 ;int n1 =0 ;
System.out.println(n1);
System.out.println (n2);
int sum ;
for ( int i = 0;i <25 ;i++)
{
sum = n1+n2;
n1 = n2 ;
n2 = sum;
System.out.println ( sum );
}

}
}

``` admin February 18, 2014 0 Comments

## checking prime number

``` import java.util.Scanner ;
class CheckPrime
{
public static void main ( String s[] )
{
System.out.println ( " Enter a number: ");

Scanner value = new Scanner ( System.in );
int number = value.nextInt ( );
int flag =0;
int c = (int) Math.sqrt( number );

for ( int i = 2 ; i <=c ; i++ )
{
if ( (number % i ) == 0 )
{

System.out.println ( " the number" + number + " is not a prime number ");

flag =1 ; break ; }

}

if (flag == 0 )

System.out.println ( " the number is a prime number" );
}
}
``` admin February 18, 2014 0 Comments

## Palindrome Program in Java

In this program, you’ll learn to check whether a number is palindrome or not in Java. This is done by using for and while loop. ## Palindrome number in java:

A palindrome number is a number that is same after reverse. For example 141, 757, 38583, 747, 171, 52925 are the palindrome numbers. It can also be a string like LOL, NITIN etc.

## Palindrome number algorithm

• Get the number to check for palindrome
• Hold the number in temporary variable
• Reverse the number
• Compare the temporary number with reversed number
• If both numbers are same, print “palindrome number”
• Else print “not palindrome number”

## Java program for checking palindrome number :

```import java.io.* ;
import java.util.Scanner;
class CheckPalindrome
{
public static void main (String s[] )
{

Scanner console = new Scanner(System.in);
int number ;

System.out.println( " Enter the array size " );
int size = console.nextInt();

int array[] = new int[size];
for ( int i=0; i<size;i++)
{
System.out.println ( "Enter the number : array["+i+"]");
number = console.nextInt() ;

array[i] = number ;
}

int c = array.length-1 ;
for ( int i = 0; i < array.length ; i++)
{
if ( array[i] == array[c])
{
c--;
}
}

if (c == (-1) )
{
System.out.println ( " this array is a palindrome ");
}
else
{System.out.println( " this is not a palindrome " );
}
System.out.println( " this is the second method to solve palindrome " );

int flag1 = 1;
for(int i = 0, k = array.length-1; i<array.length&k>(-1);i++,k--)
{
if ( array[i] != array[k])
{
System.out.println ("this is not a palindrome");
flag1 = 0; break ;
}

}
if (flag1==1){
System.out.println( " this is a palindrome " );
}
}
}``` admin February 18, 2014 0 Comments

## Java program for checking even and odd number

```import java.util.Scanner;
class Check
{
public static void main ( String []s)
{

Scanner value = new Scanner( System.in);
System.out.println ( " Enter the number : ");
int number = value.nextInt();

if ( number %2 == 0)
{
System.out.println ( " the number "+ number + " is even number ");
}
else
{ System.out.println( " the number is odd " );
}
System.out.println( " using bitwise and operator " );
System.out.println ( " Enter another number ; ");
Scanner abc = new Scanner( System.in );
int number1 = abc.nextInt();
if ( (number1 & 1) == 0)
{
System.out.println ( " it is an even number ");
}
else
{ System.out.println ( " it is an odd number " );
}

}
}``` admin February 18, 2014 0 Comments

## program on break apart a number in java admin February 18, 2014 0 Comments