Wednesday, January 16, 2008

Fibonacci Series

import java.io.*;
class fibonacci
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n,a=0,b=1,i,c;
System.out.println(" Enter any number ");
n = Integer.parseInt(br.readLine());
System.out.println(a+"\t"+b);
for(i=1;i<=n;i++)
{
c=a+b;
System.out.println("\t" +c);
a=b;
b=c;
}
}
}

2 comments:

Anonymous said...

/t ? meaning?

anonymous said...

/t means tab space. it gives a little more space then normal space. it is an escape sequence. an escape sequence is a letter with backslash which perform a particular function. the backslash makes the letter t a special character to be used as a symbol for tab space