package com.swain.cell;
public class Piramid2 {
public static void main(String args[]){
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
}
}
//PIRAMID3
public class Piramid2 {
public static void main(String args[]){
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
}
}
//PIRAMID3
package com.swain.cell;
public class Piramid3 {
public static void main(String args[]){
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
for(i=4;i>=1;i--)
{
for(j=1;j<=i;j++)
System.out.print(" "+j);
System.out.print("\n");
}
}
}
//PIRAMID4
package com.swain.cell;
public class Piramid4 {
public static void main(String args[]){
int i,k,j;
for(i=1;i<=200;i= i*2){
for(j=1; j<=i; j=j*2)
System.out.print(j + " ");
for(k=i/2; k>=1; k=k/2)
System.out.print( k + " ");
System.out.print("\n");
}
}
}
//PRIME NO IN JAVA
package com.swain.cell;
public class Prime {
public static void main(String args[])
{
int n, status = 1, num = 3;
n=5;
if ( n >= 1 )
{
System.out.println("prime numbers are: ");
System.out.println(2);
}
for ( int count = 2 ; count <=n ; )
{
for ( int j = 2 ; j <= Math.sqrt(num) ; j++ )
{
if ( num%j == 0 )
{
status = 0;
break;
}
}
if ( status != 0 )
{
System.out.println(num);
count++;
}
status = 1;
num++;
}
}
}
No comments:
Post a Comment