miércoles, 10 de octubre de 2012

Programación Java: Factorial

Código realizado en Netbeans 7.2


/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package factorial; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author Salvador */ public class Factorial { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { double N,Factorial=1; System.out.print("Introduzca Numero a Factorizar:"); BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); N=Double.parseDouble(br.readLine()); while(N>1){ Factorial=Factorial*N; N=N-1; } System.out.println("El factorial es: "+Factorial); } }

0 comentarios:

Publicar un comentario