Monthly Archives: June 2013

Factorial digit sum: Project Euler Problem 20

Problem link: http://projecteuler.net/problem=20

Problem Statement:
n! means n\times(n-1)\times...\times2\times1

For example, 10! = 10 \times 9 \times ... \times 3 \times 2 \times 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.

Find the sum of the digits in the number 100!

Continue reading

Advertisements

10001st prime: Project Euler Problem 7

Problem link: http://projecteuler.net/problem=7

Problem Statement:
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?

Continue reading

Smallest multiple: Project Euler Problem 5

Problem link: http://projecteuler.net/problem=5

Problem Statement:
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?

Continue reading

DancingSentence : TopCoder Problem 5950

[The problem appeared in TopCoder SRM 279 (Div-2, Level-1) and SRM 279 (Div-1, Level-1)]

Problem link: http://community.topcoder.com/stat?c=problem_statement&pm=5950&rd=8076

Problem Statement:
A sentence is called dancing if its first letter is uppercase and the case of each subsequent letter is the opposite of the previous letter. Spaces should be ignored when determining the case of a letter. For example, “A b Cd” is a dancing sentence because the first letter (‘A’) is uppercase, the next letter (‘b’) is lowercase, the next letter (‘C’) is uppercase, and the next letter (‘d’) is lowercase.

You will be given a String sentence. Turn the sentence into a dancing sentence by changing the cases of the letters where necessary. All spaces in the original sentence must be preserved.
Continue reading