WAP to print fibnacci series upto 20 terms
Answers
Answered by
1
class Fibnacci
{
void main()
{
int a=0,b=1,c,count=2;
System.out.print(a+",");
System.out.print(b+",");
while(count!=20)
{
c=a+b;
count++;
System.out.print(c+",");a=b;b=c;
}
}
}
This is my first fibnacci program so plz dont be angry If i'm wrong.
{
void main()
{
int a=0,b=1,c,count=2;
System.out.print(a+",");
System.out.print(b+",");
while(count!=20)
{
c=a+b;
count++;
System.out.print(c+",");a=b;b=c;
}
}
}
This is my first fibnacci program so plz dont be angry If i'm wrong.
Shridhar023:
I did this before
class armstrong
{
public static void main(String args[])
{
armstrong obj= new armstrong();
int i,n,sum,m;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number : ");
n=sc.nextInt();
m=obj.checknum(n);
if(n==m)
System.out.println("It is a armstrong number");
else
return (int)Math.pow(n%10,3)+ checknum(n/10);
}
}
class prime
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(" Enter any no,");
int a = Integer.parseInt(br.readLine());
int fac=0;
for(int i =2;i{
if(a%i==0)
fac=1;
break;
}
if(fac==0)
System.out.println("Prime Number");
else
System.out.println("Not Prime Number");
}
}
Similar questions