6 kyu

Pure odd digits primes

383 of 1,038raulbc777

Description:

Primes that have only odd digits are pure odd digits primes, obvious but necessary definition. Examples of pure odd digit primes are: 11, 13, 17, 19, 31... If a prime has only one even digit does not belong to pure odd digits prime, no matter the amount of odd digits that may have.

Create a function, only_oddDigPrimes(), that receive any positive integer n, and output a list like the one below:

[number pure odd digit primes below n, largest pure odd digit prime smaller than n, smallest pure odd digit prime higher than n]

Let's see some cases:

only_oddDigPrimes(20) ----> [7, 19, 31]
///7, beacause we have seven pure odd digit primes below 20 and are 3, 5, 7, 11, 13, 17, 19
19, because is the nearest prime of this type to 20
31, is the first pure odd digit that we encounter after 20///

only_oddDigPrimes(40) ----> [9, 37, 53]

In the case that n, the given value, is a pure odd prime, should be counted with the found primes and search for the immediately below and the immediately after.

Happy coding!!

Fundamentals
Algorithms
Mathematics
Data Structures

Stats:

CreatedAug 28, 2015
PublishedAug 28, 2015
Warriors Trained3075
Total Skips320
Total Code Submissions5349
Total Times Completed1038
Python Completions383
Ruby Completions72
JavaScript Completions260
Java Completions147
CoffeeScript Completions6
C# Completions82
Haskell Completions35
Clojure Completions11
C++ Completions57
C Completions60
Total Stars74
% of votes with a positive feedback rating92% of 256
Total "Very Satisfied" Votes217
Total "Somewhat Satisfied" Votes35
Total "Not Satisfied" Votes4
Ad
Contributors
  • raulbc777 Avatar
  • g964 Avatar
  • smile67 Avatar
  • ParanoidUser Avatar
  • Voile Avatar
  • rowcased Avatar
  • hobovsky Avatar
  • akar-0 Avatar
  • 66  Avatar
  • saudiGuy Avatar
Ad