Problem 1
来源:互联网 发布:python 定义矩阵 编辑:程序博客网 时间:2024/04/28 00:29
# -*- coding = gbk -*-#!/usr/bin/python'''Problem1: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.'''def findnumbers (number): i = 1 n = 0 sum = 0 while (i<number): if i%3 == 0 or i%5 == 0: sum = sum + i n = n + 1 i = i + 1 print unicode(" %d %d" %(sum, n)) findnumbers(10)findnumbers(100)findnumbers(1000)
0 0
- Problem 1
- Problem 1
- problem 1
- problem-1
- problem 1
- Problem 1
- Problem 1
- Problem 1
- 3n+1 Problem, aka Collatz Problem
- Projecteuler Problem 1-10
- Problem 1_03_guess
- Hibernate: N+1 problem
- Problem 1 of multiples
- Project Eurler - Problem 1
- Project Euler problem 1
- hdu1032 The3n+1problem
- 1:A+B Problem
- 图论-Problem.1
- 字符串常用方法
- 大话云计算
- centos php 安装memcached 扩展 支持sasl
- JQuery防止退格键网页后退
- NSString使用整理
- Problem 1
- 洪涝淹没分析输出淹没范围图、深度图及面积体积等信息
- node.js 抓取全国区域代码、邮政编码、电话区号
- 怎么阅读源码
- android学习一---搭建开发环境
- Android Looper详解
- 1《大话操作系统——做坚实的工程实践派》(8.1)(指令集未完待续)
- NSRange 用法
- JavaWeb_JavaEE_命名规则