Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ challenge

Name: Anonymous 2013-03-18 1:53

Write a program which will express an integer using only the number 2 (with the exception of 0 for exponents), using any mathematical operations to do so. Try to make it express the amount efficiently, rather than the easy and lazy way of 2+2+2... for evens and 2+2+2... -2^0 for odds.
Any language is acceptable.
For example:
anus@prog ~ $ ./2 num=50
(((2^(2+2+2))-2^(2+2))+2)
anus@prog ~ $

Name: Anonymous 2013-03-18 18:50

It would actually be pretty neat if you could recursively define the powers of two in binary in order to implement this. Like to represent 8 you would need 2^3, so first you'd have to represent 3 which would be 2^1 + 2/2, etc.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List