Magic constant: Difference between revisions

Line 184:
</pre>
 
 
=={{header|Perl}}==
<lang perl>#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Magic_constant
use warnings;
 
my @twenty = map $_ * ( $_ ** 2 + 1 ) / 2, 3 .. 22;
print "first twenty: @twenty\n\n" =~ s/.{50}\K /\n/gr;
 
my $thousandth = 1002 * ( 1002 ** 2 + 1 ) / 2;
print "thousandth: $thousandth\n\n";
 
print "10**N order\n";
for my $i ( 1 .. 20 )
{
my $want = 10 ** $i;
printf "%3d %9d\n", $i, (10 ** $i * 2) ** ( 1 / 3 ) + 1;
}</lang>
{{out}}
<pre>
first twenty: 15 34 65 111 175 260 369 505 671 870
1105 1379 1695 2056 2465 2925 3439 4010 4641 5335
 
thousandth: 503006505
 
10**N order
1 3
2 6
3 13
4 28
5 59
6 126
7 272
8 585
9 1260
10 2715
11 5849
12 12600
13 27145
14 58481
15 125993
16 271442
17 584804
18 1259922
19 2714418
20 5848036
</pre>
 
=={{header|Phix}}==
Anonymous user