Project Euler__problem 1
来源:互联网 发布:python求平均值函数 编辑:程序博客网 时间:2024/06/07 05:41
在一个师兄那里看到在刷Project Euler
感到兽血沸腾,有种刷题的冲动
首先就比较简单的第一题做起
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
3的倍数和5的倍数
如果我们列出10以内所有3或5的倍数,我们将得到3、5、6和9,这些数的和是23。
求1000以内所有3或5的倍数的和。
首先求出1000以内的3与5的最大倍数
在对其求和剩余提出来的3或5 再相加
编程也十分简单
#include<iostream>void fun(int n){int sum = 0, num;for (num = 1; num < n; num++)if (num%3==0||num%5==0) sum += num;std::cout << "Output:" << sum << std::endl;}void main(){fun(1000);system("pause");}
可知结果是233168
阅读全文
1 0
- Project Euler__problem 1
- Project Euler__problem 2
- Project Euler__problem 3
- Project Euler__problem 4
- Project Euler__problem 5
- Project Euler__problem 6
- Project Euler__problem 7
- Project Euler__problem 8
- Project Euler__problem 9
- Project Euler__problem 10
- Project Explorer (1) -- "Build Project" 和 "Clean Project"
- Project Diary - 1
- Project Euler 1-6
- Project-1项目里程碑
- Project Eurler - Problem 1
- Project Euler #1
- Project Euler problem 1
- Project Euler 1~5
- generic
- java三大框架原理
- jsp测试servlet的生命周期
- Tuffy
- Java集合系列(四)
- Project Euler__problem 1
- SDUT—2772—数据结构实验之串一:KMP简单应用
- eclipse新建tomcat server但是总是报404的解决方法
- tomcat设置IP地址或者域名访问
- 希尔排序 Python实现
- 闲话云安全(1)_安全参考模型
- Java开发中的23种设计模式详解
- 适配器模式(adapter)c++版本
- kamon文档翻译(四)--trace订阅协议