首先要知道exp()函数
exp(n)值为e^n次方;
另外log函数包括两种函数 一种以e为底的log()函数
另一种为以10为底的log 10()函数;
另外如果自定义以m为底,要用到换底公式
log(8)/log(2) 表示以2为底,8的对数 log2(8)
#include<iostream>
#include<cmath>//注意log函数在math.h库函数中
using namespace std;
int main()
{
cout<<log(100)<<endl;//以e为底
cout<<log10(100)<<endl;//以10为底
cout<<log(7)/log(2)<<endl;//以2为底7的对数
return 0;
}
阶乘位数:
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main() {
ios::sync_with_stdio(false);
cout.tie(0);
double len = 1;
for(int i = 1; i <= 10000; i++)
{
len += log10(i);
}
cout << len << endl;
return 0;
}
10000 阶乘位数为: 35660位。