Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions AlphabetPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class AlphabetPattern{
public static void main(String args[]){
char c = 'A';

for(int i = 0; i < 5; i++){
for(int j = 0; j <= i; j++)
System.out.print((char)(c + j) + " ");
System.out.println();
}
}
}
25 changes: 25 additions & 0 deletions Factorial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.math.BigInteger;
import java.util.Scanner;

public class Factorial {
static BigInteger x;

static BigInteger factorial(int n) {
for(n = n - 1; n > 1; n--)
x = x.multiply(BigInteger.valueOf(n));

return x;
}

public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);

System.out.print("Enter a whole number to display its factorial: ");
int n = scanner.nextInt();
x = new BigInteger(Integer.toString(n));

System.out.println("Factorial of " + n + " is: " + factorial(n));

scanner.close();
}
}