πŸ“˜ Multiplying big numbers using Perl 6

πŸ“˜ Multiplying big numbers using Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.


Create a program to multiply very big integer numbers.

In Perl 6, the support for big numbers is built-in: the Intclass allows arbitrary precision. You do not have to do any extra work. You just take the numbers and multiply them, as shown in the example (numbers should be written on one line, and without spaces, of course):

my $a =
   83274938493874832658327320948349783624839479683297463483
   72463286948532460989746932849382643928497328656329878246
   39847823659328476832647392847836539843928645384329463287
   53924837825643824302487637563724384782374803284710339876;

my $b =
   23849389520394874100302935470340851094327485279287346539
   23423599234023403275324932549011093234845878830238479823
   38497357295682768498203985784582309487857450938547650202
   34958452087248754293875293059257429584375683984543867549;

say $a * $b;

Run the program and check the result πŸ™‚

$ perl6 multiply.plΒ 
1986056445427346134608816461674104817709618067621430859563207941437226572258175727633535561316010373307679877834702680894647645044003396073107877542993756465549631283276980805936731731567112322543695408638461054692799962710717063045632562953661655028129020817093482213746516429627686325589675507869799601220291149025456557025548354675233652370552962102165098346321376325794905191426940032936330373925095492741926233188581116641016422307707317083924

Leave a Reply

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code