Girilen sayının faktoriyelini hesaplayıp gösteren programı yazın.
Kod:
package elif;
import java.util.Scanner;
public class whileee {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner al=new Scanner(System.in);
int a;
int i=1;
int faktoriyel=1;
System.out.print("Sayı gir: ");
a=al.nextInt();
while (i <= a)
{System.out.println(i);
faktoriyel=faktoriyel*i;
i++;
}
System.out.print("sayının faktoriyeli: " +faktoriyel);
}
}