login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A163974 Number of ways to write n as the root-mean-square (RMS) of a set of distinct primes. 5
0, 1, 1, 0, 1, 0, 1, 0, 2, 0, 3, 0, 7, 0, 3, 3, 11, 1, 11, 2, 11, 3, 37, 0, 44, 18, 52, 24, 103, 50, 147, 52, 214, 170, 475, 229, 711, 375, 1116, 587, 2101, 542, 3009, 1940, 4870, 1680, 8961, 5923, 16712, 4190, 24098, 11552, 42715, 11347, 69608, 32495, 103914, 50493, 189499, 103581, 304367, 152520, 453946, 203153, 783817, 246991, 1345661 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,9
LINKS
Eric Weisstein's World of Mathematics, Root-Mean-Square
EXAMPLE
a(13) = 7 because 13 is the RMS of 7 sets of distinct primes: 13 = RMS(13) = RMS(7,17) = RMS(5,11,19) = RMS(7,13,17) = RMS(5,11,13,19) = RMS(5,7,11,17,19) = RMS(5,7,11,13,17,19).
MAPLE
sps:= proc(i) option remember; `if`(i=1, 4, sps(i-1) +ithprime(i)^2) end: b:= proc(n, i, t) if n<0 then 0 elif n=0 then `if`(t=0, 1, 0) elif i=2 then `if`(n=4 and t=1, 1, 0) else b(n, i, t):= b(n, prevprime(i), t) +b(n-i^2, prevprime(i), t-1) fi end: a:= proc(n) option remember; local s, k; s:= `if`(isprime(n), 1, 0); for k from 2 while sps(k)<=k*n^2 do s:= s +b(k*n^2, nextprime(floor(sqrt(k*n^2 -sps(k-1)))-1), k) od; s end: seq(a(n), n=1..30);
MATHEMATICA
sps[i_] := sps[i] = If[i == 1, 4, sps[i - 1] + Prime[i]^2]; b[n_, i_, t_] := b[n, i, t] = If[ n < 0 , 0 , If[ n == 0 , If[t == 0, 1, 0], If[ i == 2 , If[n == 4 && t == 1, 1, 0], b[n, NextPrime[i, -1], t] + b[n - i^2, NextPrime[i, -1], t - 1]]]]; a[n_] := a[n] = (s = Boole[PrimeQ[n]]; For[k = 2, sps[k] <= k*n^2, k++, s = s + b[k*n^2, NextPrime[ Floor[ Sqrt[k*n^2 - sps[k - 1]]] - 1], k]]; s); Table[ Print[a[n]]; a[n], {n, 1, 58}] (* Jean-François Alcover, Jul 11 2012, translated from Maple *)
PROG
(Haskell)
a163974 n = f a000040_list 1 nn 0 where
f (p:ps) l nl xx
| yy > nl = 0
| yy < nl = f ps (l + 1) (nl + nn) yy + f ps l nl xx
| otherwise = if w == n then 1 else 0
where w = if r == 0 then a000196 m else 0
(m, r) = divMod yy l
yy = xx + p * p
nn = n ^ 2
-- Reinhard Zumkeller, Feb 13 2013
CROSSREFS
Cf. A072701.
Sequence in context: A249431 A331176 A076563 * A317443 A308218 A067165
KEYWORD
nice,nonn
AUTHOR
Alois P. Heinz, Aug 07 2009
EXTENSIONS
Terms a(59)-a(67) by Reinhard Zumkeller, Feb 13 2013
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 11:42 EDT 2024. Contains 371779 sequences. (Running on oeis4.)