Jawaban #7 log(n!) Logaritma n faktorial

// -------------------------------------------------------
// Author : Asadullohil Ghalib - gadzata@gmail.com
// -------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main(){
	double jmlcase, hasil[1000];
	int faktorial, x[1000];

	cout << "--------- Mencari nilai Log(x!) ---------" << endl;
	cout << "Jumlah Testcase : "; cin >> jmlcase;
	for (int i=1;i<=jmlcase;i++){
		cout << "Masukkan nilai x -" << i << " : " ; cin >> x[i];
		faktorial = 1;

		for(int s=1;s<=x[i];s++){
			faktorial *= s;
		}

		hasil[i] = log10(faktorial);
	}
	for (int i=1;i<=jmlcase;i++){
		cout << "Hasil Log(" << x[i] << "!) = " << fixed << setprecision(2)<< hasil[i] << endl;
	}

	return 0;
}

One thought on “Jawaban #7 log(n!) Logaritma n faktorial

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s