Egyptian fraction by nn

main(a,b,n,c){for(;~scanf("%d/%d",&a,&b);printf(" + 1/%lld\n",(1ll*b*n)/a))for(vprintf(),n=2,c='=';n*a>b?a=n*a-b,printf(" %c 1/%d",c,n),c='+',(1ll*b*n)%a?b*=n:0:1;n++);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page