0

1.Sexy primes are prime numbers that differ from each other by six. For example, the first 5 sexy prime pairs are (5, 11), (7, 13), (11, 17), (13, 19), (17, 23). Find the number of sexy prime pairs (p, p + 6) such that p ≤ 201415.

2.For each positive number n, define S(n) to be the sum of all its digits. For example, S(2014) = 2 + 0 + 1 + 4 = 7. Find S(2014^{2014}).

ross999
  • 187
  • for question 1 what I did is that I tried to find the nth prime number before 201415 and then subtract 2 from it to get the number of sexy prime. I got 18090 as answer. Is this correct? – ross999 Nov 11 '14 at 23:33
  • Can someone explain how to do number 2? – ross999 Nov 11 '14 at 23:34

1 Answers1

2

There are no mathematical tricks involved. This is pure brute-force but entirely straightforward Maple coding. The coding is easy in each case and executes in seconds or less.

Problem 1: Your solution technique is way off. In Maple,

n:= 0:
p:= 2:
while p <= 201415 do
     if isprime(p+6) then n:= n+1 end if;
     p:= nextprime(p)
end do:
n;

The returned answer is 4317.

Problem 2: Don't let numbers with thousands of digits scare you. Maple handles them in an instant. This one is a one-liner:

`+`(convert(2014^2014, base, 10)[]);

The returned answer is 29761.

Carl Love
  • 1,193
  • What does the [] do here? – GFauxPas Nov 12 '14 at 00:33
  • If L is a list (or set), then L[] is the corresponding sequence. One way to think of it is that [] removes the square brackets from a list. – Carl Love Nov 12 '14 at 00:35
  • @CarlLove. Thank you. Im new to maple. I got another question. Suppose I want to bisect an angle and obtain the coordinates of the coordinates where the line cuts the triangle. is there a way to do this in maple? – ross999 Nov 12 '14 at 00:40
  • Your question is not specific enough. Anyway, it is a separate question, so it doesn't belong here. – Carl Love Nov 12 '14 at 02:01