OFFSET
1,1
COMMENTS
_ _ _ _ _ _ _ _
| | | _| _| |_| |_ |_ | |_| |_|
|_| | |_ _| | _| |_| | |_| _|
.
FORMULA
EXAMPLE
For n = 6, prime(6) = 13, which has two digits: 1, 3. We need two segments for the 1 and five for the 3 (see the Comments section), so a(6) = 2 + 5 = 7.
MAPLE
a:= n-> add([6, 2, 5, 5, 4, 5, 6, 3, 7, 6][i+1], i=convert(ithprime(n), base, 10)):
seq(a(n), n=1..100); # Alois P. Heinz, Jun 20 2018
MATHEMATICA
f[n_] := Plus @@ (IntegerDigits@n /. {0 -> 6, 1 -> 2, 2 -> 5, 3 -> 5, 7 -> 3, 8 -> 7, 9 -> 6}); f@# & /@ Prime@ Range@ 71 (* Robert G. Wilson v, Jun 20 2018 *)
PROG
(PARI) {
v=vector(10);
v[1]=6; v[2]=2; v[3]=5; v[4]=5; v[5]=4; v[6]=5; v[7]=6; v[8]=3; v[9]=7; v[10]=6;
forprime(n=2, 1000,
d=digits(n, 10); s=0;
for(i=1, #d,
s+=v[d[i]+1];
)
; print1(s", ")
)
}
(Python)
from sympy import prime
def A302552(n):
return sum((6, 2, 5, 5, 4, 5, 6, 3, 7, 6)[int(d)] for d in str(prime(n))) # Chai Wah Wu, Oct 30 2020
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Dimitris Valianatos, Jun 20 2018
STATUS
approved