Consider the prime number `23`. If we sum the square of its digits we get:
`2^2 + 3^2 = 13`, then for `13: 1^2 + 3^2 = 10`, and finally for `10: 1^2 + 0^2 = 1`. 

Similarly, if we start with prime number `7`, the sequence is: `7->49->97->130->10->1`.

Given a range, how many primes within that range will eventually end up being `1`? 

The upperbound for the range is `50,000`. A range of `(2,25)` means that: `2 <= n < 25`. 

Good luck!

If you like this Kata, please try:

[Prime reversion](https://www.codewars.com/kata/59b46276afcda204ed000094)

[Domainant primes](https://www.codewars.com/kata/59ce11ea9f0cbc8a390000ed)

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'def solve(a,b):\n    return len([x for x in [7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383, 397, 409, 487, 563, 617, 653, 673, 683, 709, 739, 761, 863, 881, 907, 937, 1009, 1033, 1039, 1093, 1151, 1277, 1303, 1373, 1427, 1447, 1481, 1487, 1511, 1607, 1663, 1697, 1733, 1847, 1933, 2003, 2039, 2063, 2111, 2221, 2309, 2333, 2339, 2383, 2393, 2417, 2557, 2693, 2741, 2833, 2851, 2903, 2963, 3001, 3019, 3067, 3079, 3083, 3109, 3137, 3209, 3301, 3313, 3319, 3323, 3329, 3331, 3371, 3391, 3463, 3607, 3637, 3643, 3673, 3709, 3779, 3797, 3803, 3823, 3833, 3907, 3923, 3931, 4111, 4127, 4157, 4217, 4271, 4363, 4441, 4447, 4481, 4517, 4663, 4721, 4751, 4817, 4871, 5147, 5227, 5281, 5417, 5471, 5477, 5527, 5569, 5659, 5741, 5821, 5879, 5897, 5987, 6037, 6053, 6073, 6163, 6197, 6203, 6329, 6337, 6343, 6353, 6361, 6367, 6373, 6389, 6637, 6661, 6673, 6701, 6703, 6719, 6733, 6763, 6791, 6803, 6899, 6917, 6971, 6983, 7039, 7127, 7309, 7331, 7451, 7457, 7481, 7541, 7547, 7589, 7603, 7691, 7793, 7841, 7937, 8081, 8147, 8233, 8369, 8521, 8597, 8693, 8699, 8741, 8821, 8929, 8963, 8969, 9001, 9007, 9013, 9103, 9133, 9203, 9323, 9377, 9587, 9623, 9689, 9829, 9857, 10009, 10039, 10067, 10093, 10141, 10151, 10177, 10211, 10247, 10303, 10333, 10337, 10427, 10457, 10487, 10607, 10663, 10733, 10771, 10847, 10903, 11113, 11131, 11149, 11159, 11197, 11243, 11251, 11311, 11423, 11467, 11471, 11483, 11491, 11519, 11681, 11719, 11941, 11971, 12011, 12101, 12143, 12149, 12347, 12413, 12437, 12473, 12491, 12511, 12583, 12671, 12743, 12823, 12841, 12853, 12941, 12959, 13003, 13009, 13033, 13037, 13093, 13177, 13241, 13309, 13339, 13411, 13421, 13457, 13487, 13499, 13577, 13679, 13697, 13757, 13841, 13903, 13933, 13967, 14011, 14057, 14081, 14087, 14207, 14281, 14321, 14327, 14347, 14387, 14407, 14437, 14449, 14461, 14537, 14549, 14551, 14561, 14723, 14753, 14783, 14813, 14821, 14831, 14939, 15101, 15121, 15299, 15377, 15451, 15461, 15473, 15541, 15641, 15679, 15737, 15773, 15787, 15823, 15877, 15887, 16007, 16063, 16097, 16127, 16217, 16363, 16417, 16451, 16603, 16633, 16741, 16759, 16811, 16937, 16993, 17027, 17033, 17107, 17137, 17191, 17207, 17317, 17443, 17483, 17569, 17573, 17609, 17627, 17659, 17669, 17713, 17827, 17911, 18041, 18047, 18143, 18223, 18253, 18341, 18401, 18413, 18523, 18587, 18743, 18757, 18839, 18899, 19141, 19259, 19333, 19421, 19699, 19763, 19889, 19963, 19979, 19997, 20063, 20147, 20177, 20333, 20369, 20393, 20639, 20693, 20717, 20771, 20899, 20903, 20963, 21011, 21101, 21143, 21149, 21283, 21341, 21347, 21407, 21419, 21481, 21491, 21599, 21617, 21767, 21787, 21841, 22129, 22229, 22273, 22291, 22381, 22483, 22549, 22573, 22621, 22651, 22783, 22861, 22921, 23039, 23227, 23369, 23417, 23447, 23581, 23609, 23663, 23741, 23827, 23887, 23893, 23899, 23977, 24071, 24107, 24113, 24137, 24181, 24229, 24317, 24371, 24473, 24683, 24859, 25057, 25111, 25183, 25237, 25261, 25453, 25561, 25621, 25657, 25801, 25849, 25919, 26003, 26171, 26177, 26227, 26251, 26267, 26309, 26339, 26393, 26557, 26627, 26633, 26669, 26711, 26717, 26821, 26903, 27017, 27107, 27143, 27253, 27283, 27299, 27397, 27431, 27611, 27617, 27697, 27701, 27739, 27793, 27817, 27823, 27883, 27967, 28051, 28081, 28099, 28123, 28351, 28387, 28393, 28411, 28463, 28513, 28549, 28621, 28643, 28723, 28771, 28789, 28837, 28879, 28909, 28933, 29033, 29063, 29221, 29297, 29303, 29363, 29383, 29389, 29411, 29633, 29833, 29927, 29983, 30013, 30029, 30091, 30097, 30103, 30109, 30133, 30137, 30139, 30269, 30293, 30313, 30319, 30323, 30367, 30391, 30553, 30637, 30643, 30661, 30689, 30713, 30763, 30803, 30869, 30931, 30977, 31033, 31039, 31177, 31247, 31307, 31393, 31481, 31547, 31663, 31699, 31769, 31771, 31847, 32009, 32069, 32083, 32141, 32257, 32303, 32309, 32369, 32411, 32609, 32693, 32779, 32797, 32803, 32839, 32887, 32983, 33013, 33023, 33029, 33071, 33083, 33091, 33107, 33203, 33289, 33301, 33359, 33391, 33413, 33589, 33629, 33829, 33931, 34127, 34147, 34157, 34211, 34217, 34313, 34471, 34499, 34603, 34721, 34747, 34781, 34871, 34897, 34919, 34949, 35053, 35227, 35281, 35339, 35393, 35569, 35603, 35771, 35839, 35933, 35983, 36007, 36037, 36061, 36067, 36073, 36209, 36263, 36293, 36307, 36343, 36433, 36559, 36607, 36637, 36791, 36809, 36919, 36923, 37013, 37097, 37117, 37171, 37441, 37447, 37489, 37517, 37571, 37619, 37663, 37691, 37907, 38069, 38189, 38239, 38287, 38299, 38303, 38329, 38333, 38593, 38609, 38669, 38749, 38891, 38923, 38953, 39023, 39103, 39133, 39301, 39313, 39419, 39619, 39623, 39671, 39727, 39749, 39761, 39799, 39829, 39847, 39979, 40009, 40087, 40111, 40127, 40471, 40577, 40609, 40751, 40841, 41011, 41047, 41057, 41081, 41113, 41117, 41131, 41183, 41213, 41231, 41281, 41333, 41357, 41381, 41387, 41399, 41507, 41549, 41617, 41641, 41651, 41761, 41801, 41813, 41911, 42017, 42071, 42131, 42181, 42283, 42437, 42473, 42589, 42683, 42701, 42743, 42859, 42863, 43063, 43133, 43271, 43313, 43331, 43427, 43499, 43517, 43633, 43721, 43781, 43789, 43987, 43991, 43997, 44017, 44041, 44071, 44159, 44249, 44273, 44371, 44453, 44491, 44519, 44543, 44633, 44647, 44651, 44699, 44701, 44773, 44789, 44879, 44939, 44959, 44987, 45077, 45137, 45161, 45289, 45317, 45491, 45523, 45553, 45641, 45707, 45853, 45949, 46141, 46171, 46411, 46447, 46451, 46499, 46511, 46663, 46997, 47041, 47051, 47057, 47111, 47123, 47143, 47161, 47351, 47381, 47389, 47407, 47431, 47501, 47507, 47513, 47699, 47743, 47857, 47939, 47969, 48017, 48121, 48131, 48259, 48311, 48371, 48397, 48449, 48479, 48497, 48623, 48731, 48757, 48799, 48947, 48973, 49121, 49139, 49193, 49211, 49391, 49451, 49459, 49549, 49697, 49739, 49783, 49789, 49937, 49943] if x in range(a,b)])\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'solve'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 5466