FANDOM


pete-3.c is one of the nine entries an anonymous "Pete" submitted to Bignum Bakeoff,[1] and the smallest entry that produces a large number. It uses the left shift operator <<, which in the fictional Bignum Bakeoff machine may be defined as \(a \ll b = a \cdot 2^b\) for nonnegative \(a\) and \(b\). (Its behavior is more complex in standard C implementations.)

Presumably to save space, Pete did not use parentheses. Unfortunately, << is left-associative, and \(a \ll b\) grows much faster relative to \(b\) than to \(a\).[2] So the returned value becomes \(9 \cdot (2^9)^{163} \cdot 2^{99} \approx 2.33 \cdot 10^{472}\), between a centillion and googolding. A large amount of space is therefore wasted on a number smaller than 1 << 1,600. If the operator was instead right-to-left associative, the output would grow at a roughly tetrational rate with respect to the number of 9's.

The full decimal expansion of this number is:
23,292,479,355,228,506,120,629,103,772,205,782,521,188,556,601,365,594,768,126,262,808,438,806,540,095,385,289,219,152,367,764,951,472,483,434,579,932,913,443,405,761,122,010,738,810,864,711,712,947,727,372,583,238,365,228,030,815,708,368,105,772,248,573,097,826,643,896,491,485,324,536,255,232,791,227,961,592,036,609,194,479,127,526,553,544,504,755,505,641,588,760,449,935,355,381,277,623,598,581,929,299,236,167,791,999,017,226,178,068,796,899,131,268,137,948,410,262,725,752,057,313,568,787,813,656,536,514,657,337,239,890,061,615,130,555,787,285,358,522,635,888,992,125,632,724,527,232,536,411,274,866,890,787,299,237,298,176

Its prime factorization is 21,566 × 32.

Code Edit

int main() 
{               
    return     
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 <<
        9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 99;  
}

Sources Edit

  1. http://djm.cc/bignum-results.txt
  2. http://en.cppreference.com/w/c/language/operator_precedence

See also Edit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.