본문 바로가기

문제풀기/프로젝트 오일러

(9)
프로젝트 오일러 문제 - Problem 9 프로젝트 오일러 문제 - Problem 9 A Pythagorean triplet is a set of three natural numbers, a
프로젝트 오일러 문제 - Problem 8 The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 6222989342338030813533627661428280644..
프로젝트 오일러 문제 - Problem 7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10 001st prime number? 10001번째 소수는 무엇인지 찾는 문제이다. 일단 소수를 판별하는 메소드를 하나 만들고,10001번째 소수가 결과로 나오면 출력한다. 소수인지 아닌지 판별하는 메소드가 핵심 포인트. public class ProjectEuler7 { private static boolean isPrime(long n){ if ((n % 2 == 0)&&(n != 2)) return false;// 2를 제외한 짝수는 소수가 아니다. for (long i = 3; i
프로젝트 오일러 문제 - Problem 6 The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. Find the difference between the sum of the squares of the first one hundred natural num..
프로젝트 오일러 문제 - Problem 5 문제) 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? 2520은 1부터 10까지 나눴을 때 나머지가 없는 수 중 가장 작은 수이다. 1부터 20까지 나눴을 때 나머지가 없는 수 중 가장 작은 수는 무엇인가? Sol.) 2520은 어떤 수인가? 1에서 10부터 존재하는 소수들만의 곱인가? 확인해보자. 2*3*5*7 = 210 이므로 아니고... 2520을 소인수분해해보면 2520 = 210 ..
프로젝트 오일러 문제 - Problem 4 문제) A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. 대칭수(?)를 찾는 문제이다. Sol.) 아주 단순하게 세자리수 곱하기 세자리수는 아무리 커봤자 6자리를 넘지 못한다. (999*999=998001) 그리고 대칭수가 되기 위해서는 자리수가 짝수여야 한다.(2자리수, 4자리수, 6자리수) 대칭수 중 가장 큰 수를 찾는 것이기 때문에, 아마 그 수는 6자리일 것이라는 가정을 하고, 곱..
프로젝트 오일러 문제 - Problem 3 문제) The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Sol.) 소인수(정확한 표현인가?)를 구하는 문제이다. 확실한 방법은 600851475143을 1부터 600851475143의 중간인 300425737571 까지 나눠보는 것이다. 그런데 어렴풋이 기억나는 방법으로는 = 약 775146 까지 나눠서 떨어지는 수 까지가 소인수이고 그 이후의 숫자들은 소인수가 아님을 보증(guarantee)한다는 내용을 어디선가 들은 것 같다. 그걸 토대로 해본다면, (시간이 많이 걸렸다. 수업 중간중간 쉬는 시간에 푸느라..) ................... impo..
프로젝트 오일러 문제 - Problem 2 이 문제는 400만 이하의 피보나치 수열중 짝수들의 합을 구하는 문제이다. 피보나치의 일반식인 을 이용해서 만들어 주고, 합계를 저장하는 변수 sum에는 짝수만 들어가게 해서 계산하면 된다. [[[[[[source code in JAVA]]]]]] import java.math.*; class Main{ public static void main (String[] args){ long[] bi = new long[32]; long sum = 0; bi[0] = (long) 1; bi[1] = (long) 2; for(int i=0; i

반응형