(Problem 1)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.
题目大意:
10以下的自然数中,属于3和5的倍数的有3,5,6和9,它们之和是23.
找出1000以下的自然数中,属于3和5的倍数的数字之和。
#include <stdio.h>
#include <string.h>
#include <ctype.h> void solve()
{
int sum,i;
sum=;
for(i=; i<; i++)
{
if(i%== || i%==)
{
sum+=i;
}
}
printf("%d\n",sum); } int main()
{
solve();
return ;
}
(Problem 1)Multiples of 3 and 5的更多相关文章
- (Problem 73)Counting fractions in a range
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...
- (Problem 42)Coded triangle numbers
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...
- (Problem 41)Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- (Problem 70)Totient permutation
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...
- (Problem 74)Digit factorial chains
The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...
- (Problem 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...
- (Problem 72)Counting fractions
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...
- (Problem 53)Combinatoric selections
There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...
- (Problem 49)Prime permutations
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual ...
随机推荐
- A Byte of Python 笔记(5)函数:定义、形参、局部变量、默认参数、关键参数
第7章 函数 函数是重要的程序段.它们允许你给一块语句一个名称,然后你可以在程序的任何地方使用这个名称任意多次地运行这个语句块.这被称为 调用 函数. 定义函数 函数通过 def 关键字定义.def ...
- 百度云世界里的“七种武器”:PCS、BAE、Site App、ScreenX等
如果说去年百度世界的关键词是“百度新首页”的话,那么今年在研发者人群中,对百度世界最深的印象就是“七种武器”,即在云的世界里,百度为开发者所提供的包括个人云存储.LBS.移动云测试中心等在内的七种工具 ...
- 在OSX狮子(Lion)上安装MYSQL(Install MySQL on Mac OSX)
这篇文章简述了在Mac OSX狮子(Lion)上安装MySQL Community Server最新版本v10.6.7的过程. MySQL是最流行的开源数据库管理系统.首先,从MySQL的下载页面上下 ...
- ThinkPHP 3.1.2 查询方式的一般使用2
//select id1> and id2< 默认是and $data['id']=array(array('gt',$id1),array('lt',$id2)); // $data[' ...
- android 构建数据库SQLite
1.首先我们需要一个空白的eclipse android工程 2.然后修改AndroidManifest.xml 在<application></application>标签里 ...
- nyoj-709-异形卵(水题)
异 形 卵 时间限制:1000 ms | 内存限制:65535 KB 难度: 描写叙述 我们探索宇宙,是想了解浩瀚星空的奥妙.但我们却非常少意识到宇宙深处藏匿的危急,它们无时无刻不紧盯着我们的地球 ...
- [Swust OJ 799]--Superprime Rib(DFS)
题目链接:http://acm.swust.edu.cn/problem/799/ Time limit(ms): 1000 Memory limit(kb): 10000 Description ...
- OpenCV配置使用版
在VS2010环境中应用Opencv,网上找到了很多配置方法,但大多都是老版本的,很多新手面对最新版本的Opencv无从下手,就给新手童鞋写了这么一篇超级详细的配置攻略,贴上来共享.要强调一点的就是, ...
- Iterator(迭代器)接口 --对象循环遍历
<?php class MyIterator implements Iterator { private $var = array(); public function __construct ...
- javascript模块加载框架seajs详解
SeaJS是一个遵循commonJS规范的javascript模块加载框架,可以实现javascript的模块化开发和模块化加载(模块可按需加载或全部加载).SeaJS可以和jQuery完美集成,使用 ...