창고/Backup_2013_0121 Q7 by 가능성1g 2012. 4. 10. 반응형 /* Main */ using System; using System.Collections.Generic; using System.Text; using System.Collections; using Utils; namespace EulerProject { class Program { static void question() { /* 10001 st 소인수 찾기 */ int cnt = 0; double index = 1; while (cnt < 10001 ) { index += 1; double pn = Utils.Math.getPrimeFactors(index); if (pn == 1 || pn == index) cnt++; } Console.WriteLine("{0} primeNumber is {1}", cnt, index); } static void Main(string[] args) { question(); } } } /* Utils */ /* Utils Class 따로 dll 파일은 만든것!! 이곳은 변경사항이 있을때만 추가적으로 보여줌 */ using System; namespace Utils { public class Math { /* 가장작은 인수를 리턴 */ public static double getPrimeFactors(double targetNumber) { double pf = 1; while (true) { pf++; if (targetNumber % pf == 0) return pf; } } } } 막 계산하는 프로그램이라 30초정도 계산후 답이 나옴 =ㅁ=ㅎㅎ 반응형 공유하기 게시글 관리 Release Center 저작자표시 비영리 동일조건 관련글 Unity3D 스크립트 오버뷰 mysql 6.0.11-alpha 윈도우 환경에서 root 패스워드를 잊어버렸을때 치트프로그램 샘플 웹어플리케이션 배포방법