Composite Number
Write a program to check if a number is composite or not.A number is composite if it has more than two factors. ex:- 4,6,8,9,10......etc.
import java.io.*;
class Numbers1{
public static void main(String args[])throws IOException{
//declare all the variables at the beginning
int n,i,j;
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Enter the number of rows : ");
n=Integer.parseInt(br.readLine());
//loop to generate the number of terms in the series
for(i=n;i>=1;i--){
for(j=1;j<=i;j++){
System.out.print(j+" ");
}//end of inner loop
System.out.println();
}//end of outer loop
}//end of main
}//end of class
Have something to say? Log in to comment on this post.
0 comments