예제 #1
0
        public static void Exercise2()
        {
            List <int> nums = new List <int>();
            int        a    = 1;
            int        b    = 2;

            while (a <= 4000000 && b <= 4000000)
            {
                nums.Add(a);
                a += b;
                nums.Add(b);
                b += a;
            }

            int res = 0;

            foreach (int n in nums)
            {
                if (n % 2 == 0)
                {
                    res += n;
                }
            }
            res.Println();
            MyExtensions.Wait();
        }
예제 #2
0
        public static void Exercise1()
        {
            List <int> nums = new List <int>();

            for (int i = 1; i < 1000; i++)
            {
                if (i % 3 == 0 || i % 5 == 0)
                {
                    nums.Add(i);
                }
            }

            int res = 0;

            foreach (int n in nums)
            {
                res += n;
            }
            res.Println();
            MyExtensions.Wait();
        }