srkp.net
当前位置:首页 >> 用php实现1+(1+2)+(1+2+3)+...+(1+2+...n) 递归求和 >>

用php实现1+(1+2)+(1+2+3)+...+(1+2+...n) 递归求和

3个错误: 1、第9行,item=1应该是item=0 2、第10行,j

#include using namespace std; int main() { int s=0,sum=0,i,n; coutn; for(i=1;i

#include"stdio.h"int sum_num(int i){ int j; int sum=0; for(j=1;j

#include void main() { int total,sum; int i,j,n; total = 0; printf("请输入题目中对应的n值: "); scanf("%d",&n); for(i = 1 ; i

float a=0,b=1,s=0; int i,n; scanf("%f",&n); for(i=0;i

Private Sub Command1_Click()Dim n As IntegerDim sum As DoubleDim Tsum As IntegerTsum = 0sum = 0n = InputBox("请输入数字N")For i = 1 To n Tsum = Tsum + i sum = sum + TsumNext iPrint sumEnd Sub

少年,这个级数是发散的,复习一下高等数学吧,计算出来是正无穷。 另外如果要求和的话建议用2L的symsum函数直接算,写循环不好。

public static void main(String[] args) { int k =100; int m = 0; for (int i = 1; i

import java.util.Scanner;public class test{ public static void main(String[] args){ Scanner s=new Scanner(System.in); System.out.println("请输入n: "); int n=s.nextInt(); int den=0; double sum=0.0; for(int i=1;i

网站首页 | 网站地图
All rights reserved Powered by www.srkp.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com