Multiples of 3 and 5
2014-03-07 07:22
375 查看
--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. --set up iterator function list_iter() local i = 1; local n = 100; return function () i = i + 1; if i < n then return i; end end end local sum = 0; for i in list_iter() do if(i % 3 == 0 or i % 5 == 0) then print(i); sum = sum + i; end end print(sum);
相关文章推荐
- Multiples of 3 and 5
- Arya and Bran & Game of the Rows & Multiple Clocks
- 1 Multiples of 3 and 5 - Project Euler
- Running Multiple Instances of Google Talk (GTalk Polygamy) and Login as Multi Users[转]
- Multiples of 3 and 5
- Method and apparatus for loading a segment register in a microprocessor capable of operating in multiple modes
- [Project Euler]Problem 1:Multiples of 3 and 5
- Multiples of 3 and 5
- Multiples of 3 and 5
- Problem 1 Multiples of 3 and 5
- 【Project Euler 1】Multiples of 3 and 5
- 【Project Euler】【Problem 1】Multiples of 3 and 5
- Project Euler #1: Multiples of 3 and 5
- Multiples of 3 and 5
- Using the multiple NICs of your File Server running Windows Server 2008 (and 2008 R2)
- Joint Tracking and Segmentation of Multiple Targets
- Project Euler #1: Multiples of 3 and 5
- 【算法题】Multiples of 3 and 5
- (Problem 1)Multiples of 3 and 5
- 【欧拉计划1】Multiples of 3 and 5