Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Factorial
- import java.util.Scanner;
- public class main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- int result = 1;
- for (int i = 1; i<=n; i++){
- result = result*i;
- }
- System.out.println(result);
- }
- }
- Sum Digits
- import java.util.*;
- class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int a = scan.nextInt();
- int sum = 0;
- while(a>0){
- sum += a%10;
- a/=10;
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment