写出求1+1/2+1/3+L+1/100的一个算法

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/29 02:41:26

写出求1+1/2+1/3+L+1/100的一个算法

in C:

double foo( void ) {
  double s, i;
  for ( s=i=0; i<100; s+=1/++i );
  return s;
}