Showing posts with label Programs. Show all posts
Showing posts with label Programs. Show all posts

Monday, April 18, 2016

Palindrome Number Program and Fibonacci Series Program

class Palindrom{
public static void main(String[] dataBag){
int number = 12121;
int palindrom = 0;
int temp = number;

while(temp>0){
palindrom = palindrom*10;
int digit = temp%10;
palindrom += digit;
temp = temp / 10;
}

if(number == palindrom){
System.out.println(number+" is a palindrom number");
}else{
System.out.println(number+" is not palindrom number");
}
}
}


class Fibonacci {
public static void main(String[] dataBag){
int ans = 0 ;
int prev = ans;
int next = 1;

do{

System.out.println(prev);
ans = prev + next;
prev = next;
next = ans;
}while(prev<=25);
}
}