2.4 Faktorial

03.42 Unknown 0 Comments

1. MENGGUNAKAN RAPTOR



2. SOURCE CODE C++

#include <iostream>
#include <string>

using namespace std;
int main()
{
   int hasil, x;


   cout <<"faktorial dari : ";
   cin >> x;
   hasil =1;
   while (!(x==1))
   {
      hasil =hasil*x;
      x =x-1;
   }
   cout << "adalah "<<hasil;
   return 0;
}


3. SOURCE CODE JAVA

import jeliot.io.*;

public class MyClass {
    public static void main() {int hasil;
int x;


   System.out.print("faktorial dari : ");
   x=Input.readInt();
   hasil = 1;
   while (!(x == 1))
   {
      hasil = hasil * x;
      x = x - 1;
   }
   System.out.print("adalah ");
   System.out.print(hasil);
    }
}

0 komentar: