The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A226230 Nontrivial prime powers (A025475) which are a sum of a smaller nontrivial prime power and a perfect square. 2

%I #10 Jun 06 2013 19:08:50

%S 8,9,25,32,81,125,128,169,289,343,512,625,1681,2048,2197,3125,3721,

%T 4913,8192,32761,32768,50653,66049,78125,97969,131072,177241,357911,

%U 524288,707281,1030301,1419857,1442401,1953125,2097152,2476099,3031081,3463321,6355441,7645373

%N Nontrivial prime powers (A025475) which are a sum of a smaller nontrivial prime power and a perfect square.

%e 81 = 32 + 7^2, so 81 is in the sequence.

%e 169 = 25 + 12^2, so 169 is in the sequence.

%p for n from 1 do

%p if isA025475(n) then

%p for j from 1 do

%p pj := n-j^2 ;

%p if pj < 0 then

%p break;

%p elif isA025475(pj) then

%p printf("%d,\n",n);

%p break ;

%p end if;

%p end do:

%p end if:

%p end do: # _R. J. Mathar_, Jun 06 2013

%o (C)

%o #include <stdio.h>

%o #include <stdlib.h>

%o #include <math.h>

%o #define TOP (1ULL<<32)

%o typedef unsigned long long U64;

%o int compare64(const void *p1, const void *p2) {

%o if (*(U64*)p1== *(U64*)p2) return 0;

%o return (*(U64*)p1 < *(U64*)p2) ? -1 : 1;

%o }

%o int main() {

%o U64 i, j, p, t, r, n=0, *pp = (U64*)malloc(TOP/2);

%o unsigned char *c = (unsigned char *)malloc(TOP/8);

%o memset(c, 0, TOP/8);

%o for (pp[n++] = i = 1; i < TOP; i+=2)

%o if ((c[i>>4] & (1<<((i>>1) & 7)))==0) {

%o for (p=i+(i==1), j = p*p; ; j*=p) {

%o pp[n++] = j;

%o double k = ((double)j) * ((double)p);

%o if (k >= ((double)(1ULL<<62)*4.0)) break;

%o }

%o if(i>1) for (j=i*i>>1; j<TOP; j+=i) c[j>>3]|= 1<<(j&7);

%o }

%o qsort(pp, n, 8, compare64);

%o for (i = 0; i < n; i++)

%o for (p=pp[i], j=0; j < i; j++) {

%o t = p - pp[j];

%o r = sqrt(t);

%o if (r*r==t) { printf("%llu, ", p); break; }

%o }

%o return 0;

%o }

%Y Cf. A025475, A226231, A226232.

%K nonn

%O 1,1

%A _Alex Ratushnyak_, May 31 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 June 17 10:05 EDT 2024. Contains 373445 sequences. (Running on oeis4.)