1+2+3+......+n
来源:互联网 发布:网络舞曲最红 编辑:程序博客网 时间:2024/04/28 09:44
Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
Input
The input will consist of a series of integers n, one integer per line.
Output
For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.
Sample Input
1100
Sample Output
15050
#include<stdio.h>int main(){ int i,n,sum; while(scanf("%d",&n)!=EOF) { sum=0; for(i=1;i<=n;i++) sum+=i; printf("%d\n",sum); printf("\n"); } return 0;}
0 0
- n=100,用递归实现:n-(n-1)+(n-2)-(n-3)........2-1;
- 求值:1!/n+3!/n*n*n+5!/n*n*n*n*n+....k!/n*n*n*n....n*n(有k个n);
- zoj 3175 Number of Containers (nbut1375) 计算n /1+n/2+n/3+n/4....+n/n
- count(n)=1!+2!+3!+.....+n!
- 1+2+3+...+n
- 1!+2!+3!+......+n!
- 1+2+3+......+n
- 1+2!+3!+...n!
- 1+2+3+....+n
- 1!+2!+3!+.....+n!
- f(n)=f(n-1)+2*f(n-2)+3f(n-3)
- 算法运行时间1、logN、N、NlogN 、N^2、N^3、2^n之间的比较
- 算法运行时间1、logN、N、NlogN 、N^2、N^3、2^n之间的比较
- LightOJ 1245 求(n/1+n/2+...+n/n)
- 输出n! n为用户输入的一个正整数 n! = n*(n-1)*(n-2)*...*1 5! = 5*4*3*2*1 = 120
- ZOJ 3175 Number of Containers(n/1+n/2+...+n/(n-1)+n/n求法)
- 1*1+2*2+3*3+++++++++n*n(用递归
- f((n)=1+1/2+1/3+.....+1/n
- 为eclipse离线安装hibernate tools插件
- Algorithms—150.Evaluate Reverse Polish Notation
- Github上README.md介绍 语法
- 简单计算器(递归写法)
- 字符串转换成数字以及注意事项
- 1+2+3+......+n
- ProtocolBuffer for Objective-C 运行环境配置(真正测试过的3.0版本编译)
- AndroidJNI.SetObjectField 设置对象域
- POJ 3186
- 希尔排序法
- 【weiphp】微官网分类列表地址获取说明
- [剑指offer]8.重建二叉树
- Android版本升级同时Sqlite数据库的升级及之前数据的保留 (
- android R文件Syntax error on token "int", VariableDeclaratorId expected after this token