# Category Archives: Project Euler

## Project Euler – Problem 7

Problem 7 from Project Euler: 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 10001st prime number? My solution: DECLARE v_cnt PLS_INTEGER := 1; v_curr PLS_INTEGER := 2; c_num_prime CONSTANT PLS_INTEGER := 10001; FUNCTION is_prime ( num_in IN… Read More »

## Project Euler – Problem 6

Problem 6 from Project Euler: 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… Read More »

## Project Euler – Problem 5

Problem 5 from Project Euler: 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? My solution: DECLARE c_step PLS_INTEGER := 20; v_sn PLS_INTEGER :=… Read More »

## Project Euler – Problem 4

Problem 4 from Project Euler: 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. My solution: DECLARE v_p PLS_INTEGER; FUNCTION is_palendrome( num_in IN NUMBER ) RETURN BOOLEAN IS… Read More »

## Project Euler – Problem 3

Project Euler – Problem 3 Problem 3 from Project Euler: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? My solution: DECLARE v_pf BINARY_INTEGER; c_num CONSTANT NUMBER := 600851475143; v_is_prime BOOLEAN := TRUE; BEGIN FOR i IN 2..floor(sqrt(c_num)) LOOP IF mod(c_num,i) =… Read More »

## Project Euler – Problem 2

Problem 2 from Project Euler: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, … By considering the terms in the Fibonacci sequence whose values do not… Read More »

## Project Euler – Problem 1

Problem 1 from Project Euler: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. My solution: DECLARE v_sum PLS_INTEGER := 0;… Read More »

## Project Euler Problems

One of my colleagues introduced me to Project Euler. From their website: What is Project Euler? Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills… Read More »