(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 ...
随机推荐
- $.ajax和vue-resource实现OAuth
Vue.js——使用$.ajax和vue-resource实现OAuth的注册.登录.注销和API调用 概述 上一篇我们介绍了如何使用vue resource处理HTTP请求,结合服务端的REST A ...
- Oracle的三种高可用集群方案
浏览了一下Oracle官方的网页以及非官方的ppt,简单了解了一下Oracle提供的高可用方案. 主要有三种: 1. RAC RAC, Real Application Clusters 多个Ora ...
- Qt中QFtp获取带有中文的文件名称出现乱码的解决方法(执行操作前就转换编码)
今天研究了一下QFtp这个类,发现访问得到的文件名称中一旦出现中文,不管怎么转换编码格式,最终显示出来的始终都是乱码.由于编码错误,我写了两个函数用于互相转换编码. 一个是由正常编码转为QFTP上所谓 ...
- 如何在同一系统中启动多个 TOMCAT
<Server port="8005" shutdown="SHUTDOWN"> 接受server关闭指令的port号.我们叫关闭指令port. & ...
- CSS引入的方式有哪些? link和@import的区别是?转载
CSS引入的方式有哪些? link和@import的区别是? HTML 中引入 CSS 的方式 有 4 种方式可以在 HTML 中引入 CSS.其中有 2 种方式是在 HTML 文件中直接添加 CSS ...
- Enze fourth day(循环语句 一)
哈喽,大家好.又到了总结知识的时间了.今天在云和学院自学了一下循环语句,下面是自己总的一些知识点. 先补充一下选择结构中的switch语句. 理论:switch语句是一种多分支选择语句,当需要测试大量 ...
- [译]Stairway to Integration Services Level 12 - 高级日志配置
介绍 本文中,我们将结合之前学习的时间冒泡,日志记录,以及复制模型.建立一个自定义的SSIS包日志模型. SSIS Task事件回顾 Reviewing SSIS Task Events 在做实 ...
- Aop编程--注解与xml的实现
一.注解方式 1.首先引入spring对于aop编程的jar支持包,spring框架没有的包请自行在网上下载. aopalliance-alpha1.jar aspectjrt.jar aspectj ...
- [C/C++基础]读写文件
1.打开.关闭文件: FILE* fp = fopen(string.c_str(), FLAG); string.c_str():需用C语言字符串形式: FLAG说明: r: 只读方式打开: w: ...
- 字符串分割函数Demo
#include <stdio.h> int getLength(char *string); int main(int argc, char **argv){ char str[12] ...