Showing posts with label Programming Contest. Show all posts
Showing posts with label Programming Contest. Show all posts

Thursday, October 20, 2011

Project Euler Problem 77 Solution

Problem Description :
It is possible to write ten as the sum of primes in exactly five different ways:
7 + 3
5 + 5
5 + 3 + 2
3 + 3 + 2 + 2
2 + 2 + 2 + 2 + 2
What is the first value which can be written as the sum of primes in over five thousand different ways?

Tuesday, October 18, 2011

Project Euler Problem 47 Solution

Problem Statement :

     The first two consecutive numbers to have two distinct prime factors are:
14 = 2 × 7
15 = 3 × 5
The first three consecutive numbers to have three distinct prime factors are:
644 = 2² × 7 × 23
                               645 = 3 × 5 × 43
                               646 = 2 × 17 × 19.
Find the first four consecutive integers to have four distinct primes factors. What is the first of these numbers?

Tuesday, October 11, 2011

Project Euler Problem 50 Solution

Project Euler Problem 50 Solution

Problem Description :
     The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953.
Which prime, below one-million, can be written as the sum of the most consecutive primes?

TJU 1156 Niven Numbers Solution




Problem Link

Solution :
    As there is no information about input number, the number can have 100 digits. So, I used string to take input. Then finding digit some will be done simply for all bases 2 <= b <= 10. After that finding modulus of a big number is the issue.
   I have used the idea that,

Saturday, October 8, 2011

Project Euler Problem 87 Solution

Project Euler Problem 87

Problem Description :
    
      The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way:

Sunday, October 2, 2011

Project Euler Problem 37 Solution

Project Euler Problem 37 Solution


   Problem Description :

   The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.

Find the sum of the only eleven primes that are both truncatable from left to right and right to left.

NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.

Saturday, October 1, 2011

Project Euler Problem 35 Solution

Project Euler Problem 35 Solution


Problem Description :
     The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.

There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.

How many circular primes are there below one million?

Wednesday, September 28, 2011

Project Euler Problem 41 Solution

Project Euler Problem 41 Solution

Problem Statement :

        We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?