5일차 1~20까지 숫자중 3의배수 이고 6의배수인 값의 합을 출력

Console Programming/C# Console 2019. 9. 24. 16:17

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax12
{
 
    class Program
    {
        static void Main(string[] args)
        {
           int sum=0;
            for (int i = 1; i <=20; i++)
            {
                if (i % 3 == 0 && i % 6 == 0)
                {
                    sum = sum + i;
                }                    
            }
            Console.WriteLine(sum);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

: