![[C#] 8일차 - 52. 합계가 10000이 넘는 순간 총 합](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FFtykf%2FbtqUwynRMOH%2FAAAAAAAAAAAAAAAAAAAAAG9KO6cDS95dpxayCk0CtO9PqpYtxVkR2-iksyTRwEd0%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DMPqj%252FYAsxQl8cFp%252FEQRxFK4JSoA%253D)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A052_UsingBreak { class Program { static void Main(string[] args) { int sum = default; // (1) for (int i = 1; ; i++) { sum += i; if(sum >= 10000) { Console.WriteLine("1~{0}의 합은 = {1}", i, sum); break; } } // (2) sum = 0; int index = 1; // 반복문이 끝났을때 출력하기 위해 index를 밖에다 선언함 ..
![[C#] 8일차 - 51. 무한루프와 break문](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbraGTA%2FbtqUtVYoVeG%2FAAAAAAAAAAAAAAAAAAAAALJsX4mPxNv3xYZiUu_MdrBM08mCRZN1D8k6mzNQyIqu%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DQA5LuTFe42Iix7qR7Zfk2W1m7JA%253D)
저금액이 얼마만에 100만원이 넘는지 알아보는 while문과 for문 예제 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A051_InfiniteLoop { class Program { static void Main(string[] args) { int sum = 0; // 총 저금액 int days = 1; // 몇일 째 인지를 의미 int money = 1000; // 그 날의 저금액 // while문으로 만듬 while (true) { sum += money; Console.WriteLine("{0,2}일차 : {1,8:C..
![[C#] 8일차 - 50. 원주율의 계산](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FFVMfU%2FbtqUvDQxcC0%2FAAAAAAAAAAAAAAAAAAAAAPP8EJ7G3mmpx01oHfw4-i9h31IPS7weCqXms9C8KqN4%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DS1N%252Bz6f9b3tak0btpMvc7QbhoCc%253D)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A050_FindingPI { class Program { static void Main(string[] args) { bool sign = false; double pi = 0; for(int i = 1; i
![[C#] 8일차 - 049. 소수 판단하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbMgQtd%2FbtqUo9pCXnG%2FAAAAAAAAAAAAAAAAAAAAAFO4ZMEDpqUnWpZIOq9XzGPQ_z9PtyltcQO-ViNBBymE%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DQvqQ6Kc9lHWFjUryuMHY0JTnRg8%253D)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A049_PrimeNumber { class Program { static void Main(string[] args) { Console.Write("숫자를 입력하세요 : "); int num = int.Parse(Console.ReadLine()); int index; for (index = 2; index < num; index++) { if(num % index == 0) { Console.WriteLine("{0}은 소수가 아닙니다.", num); break; } } if(i..
![[C#] 7일차 - 48. 팩토리얼 구하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Ftq7YK%2FbtqUtqj2n5X%2FAAAAAAAAAAAAAAAAAAAAAC55aX1gCz9uLziGddQG7coaacaUwdQSHgEvm7KRyhB0%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3D2puqCA8bI%252FpdM1xvRT%252FJsTEPsmk%253D)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A048_Factorial { class Program { static void Main(string[] args) { Console.WriteLine("n!를 계산합니다."); Console.Write("n을 입력하세요 : "); int n = int.Parse(Console.ReadLine()); int fact = 1; for (int i = 2; i