gnopaste

Sorry for this ugly message. We are searching for some translators.
Please send me an eMail or jabber: t4c@im.digital-bit.ch
Got: de, en, pl, ro, lu, ru, es - Need: everything else

Name
[java]Fattoriale
Scriptlanguage
Java
Tabwidth
4
Date
03/13/2010 01:37:48 pm
IP
151.32.237.64

[http://capiamoinsieme.bloog.it] Calcolo del fattoriale in modo ricorsivo

  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package javaapplication1;
  7. import java.util.*;
  8.  
  9. /**
  10. *
  11. * @author Administrator
  12. */
  13. public class Fattoriale {
  14.  
  15.     public static long fattoriale(int n){
  16.         if(n<=0) return 1;
  17.         else return n*fattoriale(n-1);
  18.     }
  19.     public static void main(String[] args) {
  20.     Scanner in=new Scanner(System.in);
  21.     System.out.println("Digita un intero: ");
  22.     int n=in.nextInt();
  23.     System.out.println("Il fattoriale di "+n+"รจ: "+ fattoriale(n));
  24.      
  25.       }
  26.     }
submitter » gnopaster | imprint « imprint     
» Terms of use «
» digital bit dot ch - t4c's new home «