Azra
Bronze Üye
-
- Katılım
- 11 Mart 2014
-
- Mesajlar
- 3.834
-
- Tepkime puanı
- 13
-
- ForumSAL Yaşı:
- 12 yıl 7 ay
- Kıdem:
- Forumun Eskisi
-
- Yaş
- 35
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);
}
}