-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice_Set_5.java
More file actions
83 lines (73 loc) · 2.28 KB
/
Practice_Set_5.java
File metadata and controls
83 lines (73 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.company;
import java.util.Scanner;
public class Practice_Set_5 {
public static void main(String[] args) {
// Problem 1
/*for (int i = 5; i != 0; i--){
for (int j = i; j != 0; j--){
System.out.print("*");
}
System.out.println("");
}*/
//Problem 2
/* Scanner sc = new Scanner(System.in);
System.out.print("Write number here : ");
int number = sc.nextInt();
int answer = 0;
int i = 0;
while (i!=number){
if (i%2==0){
answer += i;
}
i++;
}
System.out.println(answer);*/
//Problem 3
/* Scanner sc = new Scanner(System.in);
System.out.print("Write the digit : ");
int table = sc.nextInt();
System.out.print("Write the rows : ");
int rows = sc.nextInt();
for (int i = 1; i!=rows+1 ; i++){
System.out.println(table + " x " + i + " = " + table*i);
}*/
//Problem 4
/* Scanner sc = new Scanner(System.in);
System.out.print("Write the digit : ");
int table = sc.nextInt();
System.out.print("Write the rows : ");
int rows = sc.nextInt();
for (int i = rows; i!=0 ; i--){
System.out.println(table + " x " + i + " = " + table*i);
}*/
//Problem 5
Scanner sc = new Scanner(System.in);
System.out.print("Write the digit here : ");
int factorial = sc.nextInt();
int answer = 1;
for (int i = 1; i!=factorial+1; i++){
answer *= i;
System.out.println(answer);
}
System.out.println("The factorial of " + factorial +" is : " + answer );
//Problem 6
// int n = sc.nextInt();
// int sum = 0;
// int order = String.valueOf(n).length();
// int copy_n = n;
// int digit = 0;
// int ok = 0;
// while (n>0){
// digit = n%10;
// sum += Math.pow(digit, order);
// ok = n/10;
// n = ok;
//
// }
// if (sum==copy_n){
// System.out.println("This is a arms strong number");
// }else {
// System.out.println("This is not a arms strong number");
// }
}
}