6 kyu

Simple Fun #303: Prime Product

346 of 598myjinxin2015

Description:

Task

We know that some numbers can be split into two primes. ie. 5 = 2 + 3, 10 = 3 + 7. But some numbers are not. ie. 17, 27, 35, etc..

Given a positive integer n. Determine whether it can be split into two primes. If yes, return the maximum product of two primes. If not, return 0 instead.

Input/Output

[input] integer n

A positive integer.

0 ≤ n ≤ 100000

[output] an integer

The possible maximum product of two primes. or return 0 if it's impossible split into two primes.

Example

For n = 1, the output should be 0.

1 can not split into two primes

For n = 4, the output should be 4.

4 can split into two primes 2 and 2. 2 x 2 = 4

For n = 20, the output should be 91.

20 can split into two primes 7 and 13 or 3 and 17. The maximum product is 7 x 13 = 91

Fundamentals

Stats:

CreatedMay 24, 2017
PublishedMay 24, 2017
Warriors Trained1470
Total Skips46
Total Code Submissions2925
Total Times Completed598
JavaScript Completions346
Ruby Completions45
Python Completions223
Haskell Completions16
Total Stars45
% of votes with a positive feedback rating94% of 165
Total "Very Satisfied" Votes147
Total "Somewhat Satisfied" Votes15
Total "Not Satisfied" Votes3
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • raulbc777 Avatar
  • JohanWiltink Avatar
  • KenKamau Avatar
  • saudiGuy Avatar
Ad