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的更多相关文章

  1. (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 ...

  2. (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 ...

  3. (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 ...

  4. (Problem 70)Totient permutation

    Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...

  5. (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 ...

  6. (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 ...

  7. (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 ...

  8. (Problem 53)Combinatoric selections

    There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...

  9. (Problem 49)Prime permutations

    The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual ...

随机推荐

  1. xar安装使用方法

    xar是一种扩展的归档格式(eXtensible ARchive format),是一种开源的文件格式.xar文件在Mac OS X 10.5里是用于软件安装程序. ---------------- ...

  2. 高质量程序设计指南C/C++语言——malloc/free使用要点

  3. sql语句分析

    show profile是由Jeremy Cole捐献给MySQL社区版本的.默认的是关闭的,但是会话级别可以开启这个功能.开启它可以让MySQL收集在执行语句的时候所使用的资源.为了统计报表,把pr ...

  4. 数据库导出到excel

    项目结构同上一篇 泛型通用的写法 ExportExcel.java package excel; import java.io.OutputStream; import java.lang.refle ...

  5. Delphi 预编译指令

    <Delphi下深入Windows核心编程>(附录A Delphi编译指令说明)Delphi快速高小的编译器主要来自Object PASCAL的严谨,使用Delphi随时都在与编译器交流, ...

  6. HDOJ 1253 胜利大逃亡(bfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1253 思路分析:因为问题需要寻找到达终点的最短的距离(最短的步数),即在状态转换图上需要找出层次最浅的 ...

  7. 一个发送电子邮件的bash脚本

    第一个命令行參数会被当邮件内容发送出去 #!/bin/bash #@author Liuyang #@date 2015-02-15 Recipients=xxx@xx.com FROM=xxx@xx ...

  8. Google启封后依然不能用

    门事件周年纪念日过后一段时间,狗狗启封了,但撸主的狗狗仍旧不能用,突然想起来之前帆樯时候改动了某些配置,比方hosts文件,这个文件的路径为:C:\Windows\System32\drivers\e ...

  9. Objective-c中@interface、@implementation、@protocal

    以下 void print(); }; class AC{ }; 这时候,AI和AC是独立存在,AC不会因为没有和AI建立关系而编译错误,将AC做以下修改后,AI才和AC建立了关系,AC必须实现AI中 ...

  10. 【SqlServer数据类型、C#数据类型、SqlDbType】对应关系及转换

    // sql server数据类型(如:varchar)// 转换为SqlDbType类型public static SqlDbType SqlTypeString2SqlType(string sq ...