Saturday, May 31, 2014

Exponent: Two to the power of

Script

#!/usr/bin/perl

print ("Enter the exponent to use: ");
$exponent =<STDIN>;
chop($exponent);

print ("Two to the power of $exponent is equal to: ", 2**$exponent, "\n");


Execution

Enter the exponent to use: 8
Two to the power of 8 is equal to: 256

Enter the exponent to use: 9
Two to the power of 9 is equal to: 512

Enter the exponent to use: 10
Two to the power of 10 is equal to: 1024

Enter the exponent to use: 16
Two to the power of 16 is equal to: 65536

Enter the exponent to use: 32
Two to the power of 32 is equal to: 4294967296

Enter the exponent to use: 48
Two to the power of 48 is equal to: 281474976710656

Enter the exponent to use: 64
Two to the power of 64 is equal to: 1.84467440737096e+19

No comments:

Post a Comment