nikolas_serafini

Fatorial - first try

Oct 5th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. class Fatorial {
  2.     double result;
  3.  
  4.     double calculateFatorial(int element) {
  5.         element *= element-1;
  6.         return element;
  7.     }
  8.  
  9.     public static void main(String[] args) {
  10.         Fatorial fatorial = new Fatorial();
  11.         fatorial.result = 1;
  12.        
  13.         for (int i = 6; i >= 1; i-=2) {
  14.             fatorial.result *= fatorial.calculateFatorial(i);
  15.         }
  16.  
  17.         System.out.println("Fatorial : " + fatorial.result);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment