Stop That!
A mathcomic for Sophia Wood’s #mathober theme “truncate.” There must be a name for these primes.
Derek Orr says these are a thing! “Yes these are things!!! Right-truncatable primes: http://oeis.org/A024770″

seen from United States
seen from Italy
seen from China
seen from China

seen from Saudi Arabia

seen from Saudi Arabia
seen from United States
seen from Peru
seen from United States
seen from China
seen from United States

seen from Singapore

seen from Brazil

seen from France
seen from Russia

seen from United States

seen from United Kingdom
seen from China
seen from China
seen from China
Stop That!
A mathcomic for Sophia Wood’s #mathober theme “truncate.” There must be a name for these primes.
Derek Orr says these are a thing! “Yes these are things!!! Right-truncatable primes: http://oeis.org/A024770″

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Problem 37
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
Find the sum of the only eleven primes that are both truncatable from left to right and right to left.
NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.
import Data.Char truncationL xs | length xs > 0 = xs:(truncationL $ tail xs) | otherwise = [] truncationR xs | length xs > 0 = xs:(truncationR $ take ((length xs)-1) xs) | otherwise = [] fromDigits = foldl addDigit 0 where addDigit num d = 10*num + d isPrime :: Int->Bool isPrime x = if x == 1 then False else null [y | y<-[2..floor (sqrt (fromIntegral x))], x `mod` y == 0] isTruncatablePrime n = all (\e -> isPrime $ fromDigits e) (truncationL $ map digitToInt $ show n) && all (\e -> isPrime $ fromDigits e) (truncationR $ map digitToInt $ show n) truncatablePrimes :: [Int] truncatablePrimes = [ x | x<-[11..(10^6)], isTruncatablePrime x] main = print(foldl (+) 0 truncatablePrimes)
List Operations so by definition will be slow, not too slow though...maybe this would be faster in CLISP, someone try it..