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

%I #14 Mar 09 2018 12:10:05

%S 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,

%T 50,147,52,214,170,475,229,711,375,1116,587,2101,542,3009,1940,4870,

%U 1680,8961,5923,16712,4190,24098,11552,42715,11347,69608,32495,103914,50493,189499,103581,304367,152520,453946,203153,783817,246991,1345661

%N Number of ways to write n as the root-mean-square (RMS) of a set of distinct primes.

%H Alois P. Heinz, <a href="/A163974/b163974.txt">Table of n, a(n) for n = 1..100</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Root-Mean-Square.html">Root-Mean-Square</a>

%e 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).

%p 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);

%t 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 *)

%o (Haskell)

%o a163974 n = f a000040_list 1 nn 0 where

%o f (p:ps) l nl xx

%o | yy > nl = 0

%o | yy < nl = f ps (l + 1) (nl + nn) yy + f ps l nl xx

%o | otherwise = if w == n then 1 else 0

%o where w = if r == 0 then a000196 m else 0

%o (m, r) = divMod yy l

%o yy = xx + p * p

%o nn = n ^ 2

%o -- _Reinhard Zumkeller_, Feb 13 2013

%Y Cf. A072701.

%Y Cf. A000196, A000040, A164283, A211868.

%K nice,nonn

%O 1,9

%A _Alois P. Heinz_, Aug 07 2009

%E Terms a(59)-a(67) by _Reinhard Zumkeller_, Feb 13 2013

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 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)