Sum of (at most) 5 primes
Mathematica, 38
IntegerPartitions[n,5,Prime~Array~n,1]
C, 192-8 = 184 chars
Contains "Goldbach" consecutively (excluding punctuation), and "Tao" as well.
When the sum is less than 5 primes (i.e. always), prints zeros (16 = 0+0+0+3+13
)
Read the number from standard input: echo 30 | ./prog
.
#define T(x)for(x=0;x<=s;b=&x,c(++x))
G,o,l,d,*b,a;c(h)
{(*b-1?h<3:++*b)||c(*b%--h?h:++*b);}
main(s){
scanf("%d",&s);
T(G)T(o)T(l)T(d)T(a)o+G+l+d+a-s?0:exit(printf("%d+%d+%d+%d+%d\n",G,o,l,d,a));
}
Old version (179 chars), which can find only sums of exactly 5 primes (and therefore fails for x<10):
#define T(x)for(x=2;x<s;b=&x,c(++x))
G,o,l,d,*b,a;c(h)
{h<3||c(*b%--h?h:++*b);}
main(s){
scanf("%d",&s);
T(G)T(o)T(l)T(d)T(a)o+G+l+d+a-s?0:exit(printf("%d+%d+%d+%d+%d\n",G,o,l,d,a));
}
Explanation:
c
sets *b
to the next prime (including *b
itself if it's prime).
T
builds a for loop, which advances one of the variables G,o,l,d,a
to the next prime.
Within all for loops, we check if the sum matches, and print&exit if it does.
Brachylog, 9 bytes
~+.ṗᵐl≤5∧
Try it online!
~+. Output (.) should sum to the input,
ṗᵐ consist of all primes,
l≤5 and have length ≤ 5.
∧ (Don't unify that 5 with the implicit output variable.)