+ 2

Challenge: How many prime numbers from 1 to 1.000.000 (million) exist that are also prime numbers when you read them backwards?

Palindrome numbers are excluded (e.g. 11, 313) and single numbers as well. The first example that fulfills the requirement is 13 (--> 31). So, this example would be two prime numbers (because 31 fulfills the requirement as well), not one.

20th Sep 2017, 8:48 AM
Ben
Ben - avatar
11 odpowiedzi
+ 3
is it 1.000.000 or 1,000,000(i.e one million)
20th Sep 2017, 8:54 AM
promise orazulike
promise orazulike - avatar
+ 3
So you mean prime numbers that read from front to back and back to front are 2 distinct primes?
20th Sep 2017, 8:58 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
I had to cut it off at 10,000 as larger numbers timed out on the Code Playground https://code.sololearn.com/ckxi86DQf42u/?ref=app
20th Sep 2017, 10:00 AM
David Ashton
David Ashton - avatar
+ 2
okay i just Wrote this code now in c++ Check if it can give you What You Seek.... One Million is a very large number(better Run on a True Compiler) https://code.sololearn.com/cxwURipc5U6a/?ref=app
20th Sep 2017, 9:04 AM
promise orazulike
promise orazulike - avatar
+ 1
One million. Dots are just for readability (quite common in Germany, sorry). Thx for your comment, I edited the text
20th Sep 2017, 9:00 AM
Ben
Ben - avatar
+ 1
Yes, that would be two distinct primes. 13 has 31 and 31 has 13. Thx for your comment, I edited the text
20th Sep 2017, 9:02 AM
Ben
Ben - avatar
+ 1
Printing prime numbers ist not the task ;-)
20th Sep 2017, 9:08 AM
Ben
Ben - avatar
+ 1
@promise remove numbers that are the same as their reverse (i.e. palindromes)
20th Sep 2017, 9:11 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
if one needs primes from 1 to 1000, first find primes up to sqr(1000). i.e up to 31. from 32 to 1000 you only have to check against those primes. the primes of first and second step are the only devisors to check against up to 1000000. because you read backwards: no check of 2,4,5,6,8 hds tsd 10tsd 100tsd. so begin set 1 { 2,3,5,7 ,11,13,17,19,(23,29),31} in brackets: only devisors for next but not set of possible solution. set 2: {34<x<1000 and x has no devisor in set 1} set3:{]1000-2000[ [,3000-4000],[7000,8000], [9000-10000],[10000-20000],[30000-40000],[70000-80000]...... and no devisor in set1 and set2} if devisor is three (123) also backwards has devisor 3. (321). are there further ideas?
20th Sep 2017, 10:40 AM
Oma Falk
Oma Falk - avatar
0
You are right. One million is way too much
20th Sep 2017, 1:17 PM
Ben
Ben - avatar
0
Here is the solution with Ruby. I'm new to this stuff, so be kind if the coding seems too long for you :-) https://code.sololearn.com/cF4yVd41ZRfl/?ref=app
20th Sep 2017, 1:31 PM
Ben
Ben - avatar