Showing posts with label Programming Contest. Show all posts
Showing posts with label Programming Contest. Show all posts
Thursday, October 20, 2011
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

15 = 3

The first three consecutive numbers to have three distinct prime factors are:
644 = 2²
7
23
645 = 3
5
43
646 = 2
17
19.


645 = 3


646 = 2


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
Sunday, October 2, 2011
Project Euler Problem 37 Solution
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
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?