6 kyu

Backwards Read Primes

277 of 7,429g964

Description:

Backwards Read Primes are primes that when read backwards in base 10 (from right to left) are a different prime. (This rules out primes which are palindromes.)

Examples:
13 17 31 37 71 73 are Backwards Read Primes

13 is such because it's prime and read from right to left writes 31 which is prime too. Same for the others.

Task

Find all Backwards Read Primes between two positive given numbers (both inclusive), the second one always being greater than or equal to the first one. The resulting array or the resulting string will be ordered following the natural order of the prime numbers.

Examples (in general form):

backwardsPrime(2, 100) => [13, 17, 31, 37, 71, 73, 79, 97] backwardsPrime(9900, 10000) => [9923, 9931, 9941, 9967] backwardsPrime(501, 599) => []

See "Sample Tests" for your language.

Notes

  • Forth Return only the first backwards-read prime between start and end or 0 if you don't find any
  • Ruby Don't use Ruby Prime class, it's disabled.
Mathematics
Algorithms

More By Author:

Check out these other kata created by g964

Stats:

CreatedApr 24, 2015
PublishedApr 24, 2015
Warriors Trained25906
Total Skips5489
Total Code Submissions56599
Total Times Completed7429
Ruby Completions277
Python Completions1483
Clojure Completions87
Haskell Completions84
JavaScript Completions1213
C# Completions472
Java Completions1307
CoffeeScript Completions23
C++ Completions549
PHP Completions277
Crystal Completions13
F# Completions36
C Completions207
TypeScript Completions219
Rust Completions254
Swift Completions266
R Completions57
Shell Completions52
OCaml Completions41
Scala Completions170
Kotlin Completions256
Elixir Completions59
NASM Completions8
Julia Completions36
PowerShell Completions46
Go Completions243
Nim Completions15
Racket Completions17
Forth Completions9
Prolog Completions13
Fortran Completions7
Pascal Completions12
Raku Completions10
Perl Completions18
Elm Completions4
D Completions5
Total Stars422
% of votes with a positive feedback rating89% of 1208
Total "Very Satisfied" Votes966
Total "Somewhat Satisfied" Votes209
Total "Not Satisfied" Votes33
Ad
Contributors
  • g964 Avatar
  • jhoffner Avatar
  • GaurangTandon Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • Firefly2002 Avatar
  • monadius Avatar
  • hobovsky Avatar
  • solitude Avatar
  • user8436785 Avatar
  • WestwardLand968 Avatar
Ad