1 | /*///-----------------------------------------------------------------
2 | * Project Euler Problem 001
3 | * File Name : pe-001.c
4 | * Author : Yen-Chin,Lee
5 | * Email : coldnew.tw@gmail.com
6 | * Create Date : 2009/03/12 18:22:32
7 | * Description :
8 | *
9 | * Problem :
10 | *
11 | * If we list all the natural numbers below 10 that are multiples
12 | * of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
13 | *
14 | * Find the sum of all the multiples of 3 or 5 below 1000.
15 | *
16 | /*///---------------------------- Copyright (C) ,2009 coldnew --------
17 |
18 | #include <stdio.h>
19 | #include <stdlib.h>
20 |
21 | int main( int argc, char **argv)
22 | {
23 | int i = 0;
24 | int sum = 0;
25 | for ( i = 0; i < 1000; i++) {
26 | if (0 == i % 3 || 0 == i % 5 ) {
27 | sum += i;
28 | }
29 |
30 | }
31 | printf("%d",sum);
32 | return 0;
33 | }
34 |
2009年3月19日 星期四
Project Euler 001.c
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言