Timur69

факториал

Apr 3rd, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. package tasks3;
  2.  
  3. public class Factorial {
  4.     public static int calculateFactorial(int n) {
  5.         int result = 1;
  6.         for (int i = 1; i <= n; i++) {
  7.             result = result * i;
  8.         }
  9.         return result;
  10.     }
  11.  
  12.     public static void main(String[] args) {
  13.         System.out.println(calculateFactorial(5));
  14.     }
  15. }
Add Comment
Please, Sign In to add comment