Jump to content

Long multiplication: Difference between revisions

→‎{{header|J}}: formatting to improve clarity
(→‎{{header|J}}: formatting to improve clarity)
Line 643:
=={{header|J}}==
 
<lang j> ((+ 10x&*)/@|.@(,.&.":@[ +//.@(*/) ,.&.":@]))/ ,~2x^64
<pre>
340282366920938463463374607431768211456</lang>
((+10x&*)/@|.@(,.&.":@[+//.@(*/),.&.":@]))/ ,~2x^64
* digits: <code>,.&.": y</code>
340282366920938463463374607431768211456
<lang j> ,.&.": 123
</pre>
1 2 3</lang>
* digits: ,.&.": y
* polynomial multiplication: <code>x (+//.@(*/)) y</code> '''ref.''' [http://www.jsoftware.com/help/dictionary/samp23.htm]
<pre>
<lang j> 1 2 3 (+//.@(*/)) 1 2 3
,.&.": 123
1 4 10 12 9</lang>
1 2 3
* building the decimal result: <code>(+ 10x&*)/|. y</code>
</pre>
<lang j> (+ 10x&*)/|. 1 4 10 12 9
* polynomial multiplication: x (+//.@(*/)) y '''ref.''' [http://www.jsoftware.com/help/dictionary/samp23.htm]
15129</lang>
<pre>
or using the primitive dyad <code>#. </code> instead of <code>(+ 10x&*)/@|.</code>
1 2 3 (+//.@(*/)) 1 2 3
<lang j> (10x #. ,.&.":@[ +//.@(*/) ,.&.":@])/ ,~2x^64
1 4 10 12 9
340282366920938463463374607431768211456</lang>
</pre>
* building the decimal result: (+10x&*)/|. y
<pre>
(+10x&*)/|. 1 4 10 12 9
15129
</pre>
or using the primitive dyad #. instead of (+10x&*)/@|.
<pre>
(10x #.,.&.":@[+//.@(*/),.&.":@])/ ,~2x^64
340282366920938463463374607431768211456
</pre>
Writing directly:
<lang j> (2x^64)*(2x^64)
<pre>
340282366920938463463374607431768211456</lang>
(2x^64)*(2x^64)
340282366920938463463374607431768211456
</pre>
 
=={{header|JavaScript}}==
892

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.