Páginas

terça-feira, 21 de maio de 2019

fatorial sem orientação a objeto.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication38;
import java.util.Scanner;
/**
 *
 * @author aluno
 */
public class JavaApplication38 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner teclado = new Scanner(System.in);
        int guardar = 0;
        System.out.println("informe o numero");
        int numero = teclado.nextInt();
        guardar =+ numero;
        for(int i = guardar -1; i > 0;i--){
        guardar *= i;
        }
        System.out.println("O fatorial do numero "+numero+" é = "+guardar+".");
    }
   
}

Sem comentários:

Enviar um comentário