[go: up one dir, main page]

login
Revision History for A225927 (Bold, blue-underlined text is an addition; faded, red-underlined text is a deletion.)

Showing all changes.
Least number of prime powers greater than 1 needed to sum up to n, or 0 if n cannot be represented as a sum of prime powers.
(history; published version)
#7 by T. D. Noe at Thu May 23 13:28:40 EDT 2013
STATUS

proposed

approved

#6 by Alex Ratushnyak at Wed May 22 01:44:59 EDT 2013
STATUS

editing

proposed

Discussion
Thu May 23
13:28
T. D. Noe: Thanks!
#5 by Alex Ratushnyak at Wed May 22 01:42:53 EDT 2013
PROG

(C)

#include <stdio.h> // GCC -O3

#define TOP (1ULL<<15) // ~140 seconds // (1ULL<<17) is ok

#define TOP2 (TOP*TOP)

typedef unsigned long long U64;

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

if (*(U64*)p1 < *(U64*)p2) return -1;

return (*(U64*)p1 == *(U64*)p2) ? 0 : 1;

}

int main() {

U64 i, j, k, p, pp=1, pfp=0, *primes, *pwFlat = (U64*)malloc(TOP*2);

primes = (U64*)malloc(TOP2);

char *c = (char*)pwFlat, *f = (char*)primes, *ff;

memset(c, 0, TOP);

for (primes[0]=2, i=3; i<TOP; i+=2) if (c[i>>1]==0)

for (primes[pp++]=i, j=i*i>>1; j<TOP/2; j+=i) c[j]=1;

for (i = 0; i < pp; ++i)

for (j=primes[i]*primes[i]; j<TOP2; j*=primes[i]) pwFlat[pfp++]=j;

qsort(pwFlat, pfp, 8, compare64);

memset(f, 100, TOP2);

for (pwFlat[pfp]=TOP2, i=0; (p=pwFlat[i])<TOP2; printf("."), ++i)

for(f[p]=1, j=0; j<=i && (pp=p+pwFlat[j])<TOP2; ++j)

for(f[pp]=2, k=0; k<=j && (pfp=pp+pwFlat[k])<TOP2; ++k) f[pfp]=3;

for (k=1; k < TOP2; k++) {

if (f[k]==100) {

for (j=0, ff=&f[k], pp=99; (p=pwFlat[j]) < k; j++)

if (ff[-p] < pp) { pp = ff[-p]; if (pp<=3) break; }

f[k] = pp+1;

}

if (k<200) printf("%llu, ", f[k] > 99 ? 0 : f[k]);

else if (f[k]>4) printf("\n%llu at %llu ", f[k], k);

}

return 0;

}

Discussion
Wed May 22
01:44
Alex Ratushnyak: Alas, the program is probably too long: 33 lines, unless you delete line 30.
#4 by T. D. Noe at Tue May 21 14:24:28 EDT 2013
NAME

Least number of nontrivial prime powers greater than 1 needed to sum up to n, or 0 if n can't cannot be represented as a sum of prime powers.

STATUS

proposed

editing

Discussion
Tue May 21
14:24
T. D. Noe: Programs would be welcome.
#3 by Alex Ratushnyak at Tue May 21 00:47:40 EDT 2013
STATUS

editing

proposed

#2 by Alex Ratushnyak at Tue May 21 00:44:14 EDT 2013
NAME

allocated for Alex RatushnyakLeast number of nontrivial prime powers needed to sum up to n, or 0 if n can't be represented as a sum of prime powers.

DATA

0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 1, 2, 2, 0, 2, 3, 3, 0, 2, 1, 3, 1, 3, 2, 4, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2, 3, 2, 3, 3, 4, 3, 2, 1, 2, 3, 2, 2, 2, 4, 3, 2, 2, 2, 3, 3, 3, 3, 1, 2, 3, 3, 2, 3, 3, 4, 2, 2, 2, 3, 2, 3, 3, 3, 2, 1, 3, 3, 3, 2, 3, 4, 3, 2, 2

OFFSET

1,12

COMMENTS

Nontrivial prime powers: A025475 except 1.

EXAMPLE

26 = 9 + 9 + 8, three summands, so a(26) = 3.

CROSSREFS
KEYWORD

allocated

nonn

AUTHOR

Alex Ratushnyak, May 21 2013

STATUS

approved

editing

#1 by Alex Ratushnyak at Tue May 21 00:44:14 EDT 2013
NAME

allocated for Alex Ratushnyak

KEYWORD

allocated

STATUS

approved