数学排列问题求教!m+m*(m-1)+m*(m-1)*(m-2)*……*m!=
4个回答
展开全部
s(m)=m+m*s(m-1)
或者
s(m)=m!(1+1/2!+1/3!+1/4!+...+1/(m-1)!)=m!*(e-r(m-1))
r(m)为计算e的剩余通项,没有计算法则,只有收敛数量级估算。
或者
s(m)=m!(1+1/2!+1/3!+1/4!+...+1/(m-1)!)=m!*(e-r(m-1))
r(m)为计算e的剩余通项,没有计算法则,只有收敛数量级估算。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <iostream>
#include <string>
using namespace std;
template<int N>
struct BigNum {
int d[N];
int len;
BigNum()
{
len = 0;
}
BigNum(const char *);
BigNum<N> & operator=(int );
BigNum<N> & operator=(BigNum<N> & );
BigNum<N> & operator *=(int);
BigNum<N> & operator +=(int);
BigNum<N> & operator +=(BigNum<N> & );
BigNum<N> & operator /=(int);
int cmp(BigNum<N> &);
template<int O>
friend ostream& operator << (ostream& ,BigNum<O>&);
};
template<int N>
BigNum<N>::BigNum(const char *s){
len = strlen(s);
int t = len;
while(t){
d[len -t] = s[t-1] -'0';
t --;
}
}
template<int N>
BigNum<N> & BigNum<N>::operator=(int n){
len = 0;
do {
d[len++] = n%10;
n /= 10;
} while(n>0);
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator=(BigNum<N> & rhs){
len = rhs.len;
for(int i=0;i<len;i++){
d[i] = rhs.d[i];
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator *=(int m){
int carry = 0;
int i;
for(i=0;i<len;i++){
carry += d[i] * m;
d[i] = carry % 10;
carry /= 10;
}
while(carry){
d[len++] = carry % 10;
carry /= 10;
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator +=(int m){
int carry = 0;
int i;
carry = d[0] + m;
d[0] = carry%10;
carry /= 10;
for( i = 1; i < len && carry; i++)
{
d[i] += carry%10;
carry /= 10;
}
while(carry){
d[len++] = carry % 10;
carry /= 10;
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator +=(BigNum<N> & rhs){
int i, j, carry = 0;
for( i = 0, j = 0; i < len && j < rhs.len; i ++, j++)
{
d[i] += rhs.d[i] + carry;
carry = d[i]/10;
d[i] %= 10;
}
if(i < len)
{
if(carry)
{
for(; i < len&&carry; i ++){
d[i] += carry;
carry = d[i]/10;
d[i] %= 10;
}
}
if(carry)
d[i] = carry, len ++;
}
else if(j < rhs.len)
{
for( ; j < rhs.len; j ++){
d[j] = rhs.d[j] + carry;
carry = d[j]/10;
d[j] %= 10;
}
if(carry)
d[j] = carry, len = rhs.len +1;
else
len = rhs.len;
}
else
{
if(carry) d[i] = carry, len++;
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator /=(int dm){
int carry = 0;
int i;
for(i=len-1;i>=0;i--){
carry *= 10;
carry += d[i];
d[i] = carry / dm;
carry = carry % dm;
}
while(d[--len] ==0){
;
}
len ++;
return *this;
}
template<int N>
int BigNum<N>::cmp(BigNum<N> &rhs){
if(len != rhs.len)
return len - rhs.len;
for(int i= len-1;i>=0;i--){
if(d[i] != rhs.d[i])
return d[i] - rhs.d[i];
}
return 0;
}
template<int N>
ostream& operator << (ostream& o, BigNum<N>& rhs){
for(int i=rhs.len-1;i>=0;i--){
o << rhs.d[i];
}
return o;
}
int main ()
{
int i, j, n;
BigNum <300> sum, temp;
while( cin >> n)
{
for( i = 1; i <= n; i ++)
{
temp = 1;
for( j = 1; j <= i; j ++)
temp *= j;
sum += temp;
}
for( i = sum.len-1; i >= 0; i --)
cout << sum.d[i];
cout << endl;
}
return 1;
}
public static void main(String[] args)
{
int sum = 0;
for (int i = 1; i <= 10; i++)
{
int mul = 1;
for (int j = i; j >= 1; j--)
{
mul *= j;
}
sum += mul;
}
System.out.println(sum);
}
#include <string>
using namespace std;
template<int N>
struct BigNum {
int d[N];
int len;
BigNum()
{
len = 0;
}
BigNum(const char *);
BigNum<N> & operator=(int );
BigNum<N> & operator=(BigNum<N> & );
BigNum<N> & operator *=(int);
BigNum<N> & operator +=(int);
BigNum<N> & operator +=(BigNum<N> & );
BigNum<N> & operator /=(int);
int cmp(BigNum<N> &);
template<int O>
friend ostream& operator << (ostream& ,BigNum<O>&);
};
template<int N>
BigNum<N>::BigNum(const char *s){
len = strlen(s);
int t = len;
while(t){
d[len -t] = s[t-1] -'0';
t --;
}
}
template<int N>
BigNum<N> & BigNum<N>::operator=(int n){
len = 0;
do {
d[len++] = n%10;
n /= 10;
} while(n>0);
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator=(BigNum<N> & rhs){
len = rhs.len;
for(int i=0;i<len;i++){
d[i] = rhs.d[i];
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator *=(int m){
int carry = 0;
int i;
for(i=0;i<len;i++){
carry += d[i] * m;
d[i] = carry % 10;
carry /= 10;
}
while(carry){
d[len++] = carry % 10;
carry /= 10;
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator +=(int m){
int carry = 0;
int i;
carry = d[0] + m;
d[0] = carry%10;
carry /= 10;
for( i = 1; i < len && carry; i++)
{
d[i] += carry%10;
carry /= 10;
}
while(carry){
d[len++] = carry % 10;
carry /= 10;
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator +=(BigNum<N> & rhs){
int i, j, carry = 0;
for( i = 0, j = 0; i < len && j < rhs.len; i ++, j++)
{
d[i] += rhs.d[i] + carry;
carry = d[i]/10;
d[i] %= 10;
}
if(i < len)
{
if(carry)
{
for(; i < len&&carry; i ++){
d[i] += carry;
carry = d[i]/10;
d[i] %= 10;
}
}
if(carry)
d[i] = carry, len ++;
}
else if(j < rhs.len)
{
for( ; j < rhs.len; j ++){
d[j] = rhs.d[j] + carry;
carry = d[j]/10;
d[j] %= 10;
}
if(carry)
d[j] = carry, len = rhs.len +1;
else
len = rhs.len;
}
else
{
if(carry) d[i] = carry, len++;
}
return *this;
}
template<int N>
BigNum<N> & BigNum<N>::operator /=(int dm){
int carry = 0;
int i;
for(i=len-1;i>=0;i--){
carry *= 10;
carry += d[i];
d[i] = carry / dm;
carry = carry % dm;
}
while(d[--len] ==0){
;
}
len ++;
return *this;
}
template<int N>
int BigNum<N>::cmp(BigNum<N> &rhs){
if(len != rhs.len)
return len - rhs.len;
for(int i= len-1;i>=0;i--){
if(d[i] != rhs.d[i])
return d[i] - rhs.d[i];
}
return 0;
}
template<int N>
ostream& operator << (ostream& o, BigNum<N>& rhs){
for(int i=rhs.len-1;i>=0;i--){
o << rhs.d[i];
}
return o;
}
int main ()
{
int i, j, n;
BigNum <300> sum, temp;
while( cin >> n)
{
for( i = 1; i <= n; i ++)
{
temp = 1;
for( j = 1; j <= i; j ++)
temp *= j;
sum += temp;
}
for( i = sum.len-1; i >= 0; i --)
cout << sum.d[i];
cout << endl;
}
return 1;
}
public static void main(String[] args)
{
int sum = 0;
for (int i = 1; i <= 10; i++)
{
int mul = 1;
for (int j = i; j >= 1; j--)
{
mul *= j;
}
sum += mul;
}
System.out.println(sum);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
很简单,有纸我可以写给你,但在网页上写出那些求和公式,以及在上面标注n等,写不出来呀。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
额,复杂
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询