mirror of
https://github.com/MunGell/awesome-for-beginners.git
synced 2026-01-27 13:58:07 -08:00
Gives a pyramid consisting number
Hacktoberfest accepted
This commit is contained in:
committed by
GitHub
parent
b7cbcb1e27
commit
e318cd5381
21
FullNumberPyramid.java
Normal file
21
FullNumberPyramid.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import java.util.*;
|
||||||
|
public class FullNumberPyramid {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner sc=new Scanner(System.in);
|
||||||
|
int n=sc.nextInt();
|
||||||
|
int c=1;
|
||||||
|
for(int i=1;i<=n;i++) {
|
||||||
|
for(int j=1;j<=n-i;j++)
|
||||||
|
{
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
for(int k=1;k<=i;k++)
|
||||||
|
{
|
||||||
|
System.out.print(c++ +" ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user