Download presentation
Presentation is loading. Please wait.
Published byAustin Chapman Modified over 8 years ago
2
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true; Scanner sc=new Scanner(System.in); n= sc.nextInt();
3
for(int i=2 ; i< n/2 ; i++) { res=n%i; if( res== 0) { flag = false; break; } if( flag) System.out.println(“Prime Number”); else System.out.println(“Not Prime Number”); }
4
WAP to display an Fibonacci series Import java.util.*; Class Fibo { public static void main(string args[]) { int prev,next,sum,n; prev=next=1;
5
for( n=1; n<= 10 ; n++) { System.out.println (prev); sum=prev + next; prev=next; next =sum; }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.