40
\$\begingroup\$

Your task is to output a Magical 8 Trapezium:

        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
  • Output in your chosen language in the fewest bytes possible.
  • Note the number of spaces at the start of each line to maintain the trapezium shape.
  • Trailing spaces are allowed.
  • You can use × or the letter x - whichever you prefer.
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Related. (slightly...) \$\endgroup\$ Commented Jul 25, 2016 at 16:04
  • \$\begingroup\$ Middle spaces are required, yes? \$\endgroup\$
    – Value Ink
    Commented Jul 25, 2016 at 18:11
  • \$\begingroup\$ @KevinLau-notKenny it is, but you could always post an alternative too if it's significant. \$\endgroup\$
    – rybo111
    Commented Jul 25, 2016 at 18:49
  • \$\begingroup\$ It's 6 bytes corresponding to the 6 spaces in the middle, so no, I don't think it's significant enough. \$\endgroup\$
    – Value Ink
    Commented Jul 25, 2016 at 19:23

38 Answers 38

15
\$\begingroup\$

Python 2, 59 bytes

a=i=1
exec"print'%9d x 8 +'%a,i,'=',a*8+i;i+=1;a=a*10+i;"*9

The numbers a and i the equation a * 8 + i are generated arithmetically. Each line, i is incremented, and a has the next digit appended via a=a*10+i. For example, if a=12345, i=5, then i becomes 6, so the new a is 12345*10 + 6 which is 123456.

Storing these as numbers rather than strings lets us compute the RHS as given by the equation a*8+i, which is shorter than string reversing.

\$\endgroup\$
1
  • \$\begingroup\$ +1 for seeing this for what it is - a sum that can be generated \$\endgroup\$
    – rybo111
    Commented Jul 25, 2016 at 23:10
7
\$\begingroup\$

V, 37 bytes

i¸ 1 X 8 + 1 = 98ñYp|Eylp^Xf+$ylp

Try it online!

This contains unprintable, so here is a hexdump:

00000000: 69c2 b820 3120 5820 3820 2b20 3120 3d20  i.. 1 X 8 + 1 = 
00000010: 391b 38c3 b159 707c 4579 6c70 015e 5866  9.8..Yp|Eylp.^Xf
00000020: 2b01 2479 6c70 18                        +.$ylp.
\$\endgroup\$
5
\$\begingroup\$

05AB1E, 32 31 30 28 bytes

Code:

TG9N-ð×NLJðN"x8+ÿ="€ðJžmN£J,

Uses the CP-1252 encoding. Try it online!.

\$\endgroup\$
3
  • \$\begingroup\$ .c isn't usable here? \$\endgroup\$ Commented Jan 10, 2017 at 14:57
  • \$\begingroup\$ @carusocomputing It is, but that postdates the challenge. \$\endgroup\$
    – Adnan
    Commented Jan 10, 2017 at 15:01
  • \$\begingroup\$ Ahhh... Did not see the timestamp. \$\endgroup\$ Commented Jan 10, 2017 at 15:10
5
\$\begingroup\$

PHP, 105 89 60 57 bytes

my first golf try here (thanks to manatwork & user55641)

for(;$i++<9;)printf("%9s x 8 + $i = %s
",$s.=$i,$s*8+$i);

59

for(;$i++<9;)printf("%9s x 8 + $i = %s
",$s.=$i,$t.=10-$i);

89 (my own try)

for(;@++$i<=9;){printf("%9s x 8 + %s = %s\n",join(range(1,$i)),$i,join(range(9,10-$i)));}

105 (first)

for($j='123456789';@$j[$i++];){printf("%9s x 8 + %s = %s\n",substr($j,0,$i),$i,strrev(substr($j,-$i)));}
\$\endgroup\$
4
  • 1
    \$\begingroup\$ No need for the braces around a single statement. The $i alone better interpolate directly in the string without format specifier. \$\endgroup\$
    – manatwork
    Commented Jul 27, 2016 at 7:16
  • 1
    \$\begingroup\$ You can drop 23 more bytes with a few tricks: Changing @++$i<=9 to $i++<9 saves 2 bytes. You don't need to silence notices as they don't stop execution and under standard PPCG rules you can ignore stderr if you want to. Changing the \n to an actual newline character saves a byte. Changing the join(range(...)) bits to $s.=$i and $t.=10-$i saves 15 bytes. This works because assignments return the value assigned and is pretty much the most valuable trick I've found for golfing php. The last 5 bytes are detailed by manatwork above \$\endgroup\$
    – user55641
    Commented Jul 27, 2016 at 8:46
  • 1
    \$\begingroup\$ You can drop 2 more bytes by replacing $t.=10-$i with $s*8+$i. tio.run/##K8go@G9jXwAk0/… \$\endgroup\$
    – 640KB
    Commented Mar 8, 2019 at 22:27
  • 1
    \$\begingroup\$ That´s 59 bytes. And $s*8+$i instead of $t.=10-$i saves two more. \$\endgroup\$
    – Titus
    Commented Mar 9, 2019 at 12:45
5
\$\begingroup\$

Pyth, 32 bytes

VS9ss[*dK-9NSN" x 8 + "N" = "r9K

Try it online!

VS9ss[*dK-9NSN" x 8 + "N" = "r9K
VS9                                  # For N in 1..9
   s                                 # Join without delimiter
    s[                               # Reduce the array on + (flattens)
      *dK-9N                         # - Space, repeated K=(9-N) times
            SN                       # - The string sequence 1..N
              " x 8 + "              # - This string literal
                       N             # - N itself
                        " = "        # - This string literal
                             r9K     # - The string sequence 9..K

Thanks to @FryAmTheEggman for saving 2 bytes. Thanks to @KennyLau for saving 3 bytes.

\$\endgroup\$
3
  • \$\begingroup\$ s does not join with space - it joins with no delimiter. \$\endgroup\$
    – isaacg
    Commented Jul 27, 2016 at 4:35
  • \$\begingroup\$ @isaacg hah, and now I'm thinking I could save a byte by joining with space \$\endgroup\$
    – Ven
    Commented Jul 27, 2016 at 9:20
  • \$\begingroup\$ The byte-count would be the same. \$\endgroup\$
    – Leaky Nun
    Commented Aug 2, 2016 at 2:56
4
\$\begingroup\$

CJam, 39 38 36 bytes

Thanks to Optimizer for saving 2 bytes.

9{)_,:)9Se[" x 8 + "@S'=S9_,fm4$<N}/

Test it here.

Same byte count:

9{)_,:)9Se[]"x8+"+:\'=9_,f-Y$<]S*n}/

This requires the latest version, available on Try it online!

\$\endgroup\$
1
  • 9
    \$\begingroup\$ @Optimizer lived up to his name, then! \$\endgroup\$
    – rybo111
    Commented Jul 25, 2016 at 19:02
4
\$\begingroup\$

Python 2, 87 84 78 75 bytes

s="123456789"
n=1
exec'print"%9s"%s[:n],"x 8 + %s ="%n,s[::-1][:n];n+=1;'*9

Try it online

A previous version uses some string magic.

R=range(1,10)
for n in R:print" "*(9-n)+`R`[1:n*3:3]+" x 8 + %d = "%n+`R`[-2:27-3*n:-3]

Casting range(1,10) to a string gives [1, 2, 3, 4, 5, 6, 7, 8, 9], and this is nice since every number is only a single digit. So getting the string 123456789 from this is simple with `range(1,10)`[1::3]. The reversed range is `range(1,10)`[-2::-3]. Then, to get only as far as I want each iteration, I slice it off at either 3*n, or at 3*(9-n) (27-3*n) for the reversed digits.

\$\endgroup\$
3
  • \$\begingroup\$ You can do for n in range(1,10):print"%9s"%s[:n]+" x 8 + %s = "%n+s[::-1][:n] for 80 bytes. \$\endgroup\$ Commented Jul 25, 2016 at 20:02
  • \$\begingroup\$ s="123456789";n=1;exec'print"%9s"%s[:n],"x 8 + %s ="%n,s[::-1][:n];n+=1;'*9 saves three more! Down to 75. \$\endgroup\$
    – lynn
    Commented Jul 25, 2016 at 21:07
  • \$\begingroup\$ Nice, thanks for the help! Too bad I had to double-slice the second time... \$\endgroup\$
    – mbomb007
    Commented Jul 25, 2016 at 21:12
4
\$\begingroup\$

Perl, 49 bytes

printf"%9s x 8 + $_ = %s
",$@.=$_,$_+8*$@for 1..9

Usage

perl -e 'printf"%9s x 8 + $_ = %s
",$@.=$_,$_+8*$@for 1..9'
\$\endgroup\$
4
\$\begingroup\$

Ruby, 77 73 65 60 bytes

Try it online~

Major revamps from @manatwork

Another overhaul from @xsot

a=i=0;9.times{puts"%9d x 8 + %d = %d"%[a=a*10+i+=1,i,a*8+i]}
\$\endgroup\$
5
  • \$\begingroup\$ Seems to be shorter with format string: puts'%9d x 8 + %d = %d'%[k=[*1..i]*'',i,k.to_i*8+i]. \$\endgroup\$
    – manatwork
    Commented Jul 26, 2016 at 9:10
  • \$\begingroup\$ (1..9).map1.upto(9) \$\endgroup\$
    – manatwork
    Commented Jul 26, 2016 at 9:25
  • \$\begingroup\$ Ah, I didn't know about %9d being a formatting option to pad integers like that \$\endgroup\$
    – Value Ink
    Commented Jul 26, 2016 at 18:23
  • \$\begingroup\$ 60: a=i=0;9.times{puts"%9d x 8 + %d = %d"%[a=a*10+i+=1,i,a*8+i]} \$\endgroup\$
    – xsot
    Commented Jul 27, 2016 at 10:48
  • \$\begingroup\$ @xsot that's great! Didn't think of calculating the initial number like that. \$\endgroup\$
    – Value Ink
    Commented Jul 28, 2016 at 8:15
4
\$\begingroup\$

Java 10, 151 133 130 129 126 110 bytes

v->{String p="\n",r="";for(int n=123456789,i=9;i>0;n/=10,p+=" ")r=p+n+" x 8 + "+i+" = "+(n*8+i--)+r;return r;}

Try it online.

Explanation:

v->{                   // Method with empty unused parameter and String return-type
  String p="\n",       //  Prefix-String, starting at a newline
         r="";         //  Result-String, starting empty
  for(int n=123456789, //  Multiply-number, starting at 123456789
      i=9;i>0          //  Loop `i` in the range [9, 0):
      ;                //    After every iteration:
       n/=10,          //     Remove the last digit from the integer
       p+=" ")         //     Append a space after the prefix
    r=...+r;           //   Prepend the following to the result-String:
      p                //    The prefix-String
      +n               //    Followed by the integer
      +" x 8 + "       //    Followed by the literal String " x 8 + "
      +i               //    Followed by the loop-index `i`
      +" = "           //    Followed by the literal String " = "
      +(n*8+i--)       //    Followed by the result of that equation
  return r;}           //  Return the result-String
\$\endgroup\$
6
  • 1
    \$\begingroup\$ I think you could save bytes by using x instead of the multiplication sign. \$\endgroup\$
    – wizzwizz4
    Commented Jul 26, 2016 at 9:49
  • 1
    \$\begingroup\$ You can save a couple of bytes by initializing s to "\n" and removing "\n"+ from the for loop \$\endgroup\$
    – cliffroot
    Commented Jul 26, 2016 at 9:59
  • \$\begingroup\$ @wizzwizz4 Thanks. Should have known × is 2 bytes instead of 1 like x.. \$\endgroup\$ Commented Jul 26, 2016 at 12:00
  • \$\begingroup\$ Aren't you adding s to the result on each iteration as well? \$\endgroup\$
    – cliffroot
    Commented Jul 26, 2016 at 12:13
  • \$\begingroup\$ I know this is old, but can't you do return o instead of System.out.print(o)? Also, you can change to Java 10 and save with var and lambdas \$\endgroup\$
    – Gymhgy
    Commented Mar 8, 2019 at 19:06
3
\$\begingroup\$

C#, 113 bytes

void f(){for(int n=1,i=1;i<10;n=10*n+ ++i)Console.WriteLine(new string(' ',9-i)+n+" x "+"8 + "+i+" = "+(n*8+i));}

if you have anyway to improve this solution feel free to share.

\$\endgroup\$
2
  • \$\begingroup\$ You can save 1 byte by removing a space: ;n=10*n+ ++i in the for-loop can be changed to ;n=++i+10*n. Also, +" x "+"8 + "+ can be changed to +" x 8 + "+. to save 3 more bytes. \$\endgroup\$ Commented Jul 27, 2016 at 6:50
  • \$\begingroup\$ void f(){for(int n=1,i=1;i<10;n=++i+10*n)Console.WriteLine($"{new string(' ', 9-i)}{n} x 8 + {i} = {(n*8+i)}");} ------------ saved you a byte! \$\endgroup\$ Commented Jul 27, 2016 at 9:26
3
\$\begingroup\$

Batch, 117 bytes

@echo off
set a=         12345678987654321
for /l %%i in (1,1,9)do call echo %%a:~%%i,9%% x 8 + %%i = %%a:~17,%%i%%

Yes, that is 16 % signs on one line; that's Batch for you!

\$\endgroup\$
2
\$\begingroup\$

Haskell, 92 bytes

s=(show=<<)
[1..9]>>= \x->([x..8]>>" ")++s[1..x]++" x 8 + "++s[x]++" = "++s[9,8..10-x]++"\n"

How it works:

s=(show=<<)                   -- helper function that turns a list of numbers into
                              -- a string without delimiters, e.g. [1,2] -> "12"

[1..9]>>=                     -- for each number 1 to 9
     ([x..8]>>" ")            -- take length of [x..8] copies of a space
     s[1..x]                  -- the digits from 1 to x
     " x 8 + "                -- a string literal
     s[x]                     -- the digit of x
     " = "                    -- another string literal
     s[9,8..10-x]             -- the digits from 9 down to 10-x
     "\n"                     -- an a newline
\$\endgroup\$
2
\$\begingroup\$

Retina, 66 bytes

Byte count assumes ISO 8859-1 encoding. The leading linefeed is significant.


123456789!9 = 987654321
+`^((.)+)\B.!.(.+).
 $1!$2$3¶$&
!
 x 8 + 

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Pyke, 30 29 bytes

9Fd*~utj+9<\x8\+9i-\=ji>_dJ)X

Try it here!

9F                         )  -  for i in range(9):
  d*                          -       " " * i
        +                     -      ^ + V
       j                      -       j = V
    ~ut                       -        "123456789"
         9<                   -     ^[:9]
           \x8\+9i-\=         -    [^, "x", 8, "+", (9-i), "=", V]
                        _     -     reversed(V)
                     ji>      -      j[i:]
                         dJ   -   " ".join(^)
                            X - print(reversed(^))
\$\endgroup\$
2
\$\begingroup\$

PowerShell v2+, 85 64 58 57 52 bytes

8..0|%{" "*$_+-join(1..++$i+" x 8 + $i = "+9..++$_)}

Loops from 8 to 0 8..0|%{...} via the range operator. Each iteration, we output a string concatenation consisting of (the appropriate number of spaces " "*$_), plus a -joined string of (a range from 1 to a pre-incremented helper number ++$i, plus the middle bit " x 8 + $i = ", plus the final range from 9 to the current number $_ pre-incremented).

One big trick here is we leverage the "left-preference" for typecasting, which allows us to "add" arrays together inside the -join parens, meaning we use only one -join operator.

Example

PS C:\Tools\Scripts\golfing> .\magical-8-trapezium.ps1
        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
\$\endgroup\$
3
  • 4
    \$\begingroup\$ %{ Are your eyes alright? \$\endgroup\$
    – gcampbell
    Commented Jul 25, 2016 at 19:04
  • \$\begingroup\$ @gcampbell If your eyes looked like that, you'd be frowning, too. \$\endgroup\$ Commented Jul 25, 2016 at 19:07
  • \$\begingroup\$ Depends on how your font renders percents. \$\endgroup\$
    – gcampbell
    Commented Jul 25, 2016 at 19:08
2
\$\begingroup\$

C, 74 bytes

d(i,n){for(i=n=1;i<10;n=++i+n*10)printf("%9d x 8 + %d = %d\n",n,i,n*8+i);}
\$\endgroup\$
2
\$\begingroup\$

MATL, 38 36 35 bytes

9:"9@-Z"@:!V' x 8 + '@VO61O58@:-v!D

Try it online!

\$\endgroup\$
2
\$\begingroup\$

J, 51 bytes

(|."1|.\p),.' x 8 + ',"1]p,.' = ',"1]\|.p=:u:49+i.9

Creates the string 123456789 and then operates on prefixes and suffixes of it to create the output.

Usage

   (|."1|.\p),.' x 8 + ',"1]p,.' = ',"1]\|.p=:u:49+i.9
        1 x 8 + 1 = 9        
       12 x 8 + 2 = 98       
      123 x 8 + 3 = 987      
     1234 x 8 + 4 = 9876     
    12345 x 8 + 5 = 98765    
   123456 x 8 + 6 = 987654   
  1234567 x 8 + 7 = 9876543  
 12345678 x 8 + 8 = 98765432 
123456789 x 8 + 9 = 987654321
\$\endgroup\$
2
\$\begingroup\$

JavaScript ES6 (88)

Taking advantage of the new repeat method, backticks and templating...

i=10;for(y="";--i;)console.log(`${" ".repeat(i)+(y+=(x=10-i))} x 8 + ${x} = ${y*8+x}\n`)
\$\endgroup\$
2
  • \$\begingroup\$ nice job bro , you should consider to remove some space and use alert instead of console.log, it can save some bytes! \$\endgroup\$
    – Chau Giang
    Commented Apr 14, 2019 at 12:57
  • \$\begingroup\$ Given I answered this just before midnight I figure I was close to half asleep... I'll post an update on this soon. LOL \$\endgroup\$ Commented Apr 14, 2019 at 20:16
2
\$\begingroup\$

R, 107 103 bytes

a=1;for(i in 2:10){cat(rep("",11-i),paste(a,"x",8,"+",(i-1),"=",strtoi(a)*8+(i-1)),"\n");a=paste0(a,i)}

Ungolfed :

a=1

for(i in 2:10)
    cat(rep("",11-i),paste(a,"x",8,"+",(i-1),"=",strtoi(a)*8+(i-1)),"\n")
    a=paste0(a,i)

Result :

        1 x 8 + 1 = 9 
       12 x 8 + 2 = 98 
      123 x 8 + 3 = 987 
     1234 x 8 + 4 = 9876 
    12345 x 8 + 5 = 98765 
   123456 x 8 + 6 = 987654   
  1234567 x 8 + 7 = 9876543 
 12345678 x 8 + 8 = 98765432 
123456789 x 8 + 9 = 987654321
\$\endgroup\$
1
  • \$\begingroup\$ 96 bytes \$\endgroup\$
    – Giuseppe
    Commented Mar 8, 2019 at 16:24
2
\$\begingroup\$

APL (Dyalog Unicode), 61 52 39 bytesSBCS

↑(⍳9)((¯9↑↑),' x 8 +',⊣,'= ',↑∘⌽)¨⊂1↓⎕D

Try it online!

-9 bytes by using the 10⊥ trick to parse the number, instead of a reduction. Thanks to @Adám for -13!

Explanation:

↑    ((¯9↑↑),' x 8 +',⊣,'= ',↑∘⌽)¨⊂1↓⎕D
                                     ⎕D  ⍝ Numbers from 0 to 9
                                   1↓    ⍝ Drop the 0
 (⍳9)(                          )¨⊂      ⍝ Do 9 times, N=current
                             ↑∘⌽         ⍝ Reverse the string (9..1) and cut off N elements
                      ⊣                  ⍝ N itself
      (   ↑)                             ⍝ Drop N elements off the 1..9 string...
      (¯9↑ )                             ⍝ ...then pad it back with spaces
            ,' x 8 +', ,'= ',            ⍝ Join with a few constant strings
↑                                        ⍝ Format
\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 99 bytes

_=>[...Array(9)].map((n,i)=>`${n="        123456789".substr(i,9)} x 8 + ${++i} = ${n*8+i}`).join`\n`
_=>".........".replace(/./g,(n,i)=>`${n="        123456789".substr(i,9)} x 8 + ${++i) = ${n*8+i}\n`)

Where \n represents a literal newline character. The second version outputs a trailing newline. I came up with a formula for the numbers ('1'.repeat(9-i)+0+i)/9 but the padding was easier to do this way.

\$\endgroup\$
1
\$\begingroup\$

Brainfuck, 232 bytes

++++++++[->+>+>+++++[->+>+>+>+>+>+++<<<<<<]>->>+>++>+++<<<<<<<<]>++>+>>>+++>>>---<<<<<<[-[-<<+>>>>.<<]>+[-<+>>>>+.<<<]>.>>>>>.<<<<<.>>>.<<<.>.<.>>.<<.>>>>.<<<<.<<<<[->>>+>>>+<<<<<<]>>[-<<+>>>>>>.-<<<<]>[->>>-<<<<+>]<<<[->>>+<<<]>.>]

Try it online!

Can be golfed much further...

\$\endgroup\$
1
\$\begingroup\$

Javascript (using external library) (143 bytes)

n=>_.Range(1,9).WriteLine(v=>_.Range(0,10-v).Write("",x=>" ")+_.Range(1,v).Write("")+" x 8 + " + v + " = "+_.Range(10-v,v).Reverse().Write(""))

Link to lib: https://github.com/mvegh1/Enumerable/

Explanation of code: Create range 1 to 9, and for each value, write a line corresponding to the complex predicate. The predicate is passed the current integer value, and creates a range spanning 10-currentValue elements, in order to create that many spaces. Those spaces are concatenated with the formula part of the line, and then that is concatenated with the tailend of the range matching the number of elements as the frontend, in reverse order.

Note: In the image, the first line is off by one space because the console added a quotation mark since the return value is a string. The actual value is formatted correctly

enter image description here

\$\endgroup\$
1
\$\begingroup\$

05AB1E, 24 bytes

9Lε©LJ'x8'+®'=T®L-Jðý}.c

Try it online!

Uses a newer version than the challenge, which is now allowed.

\$\endgroup\$
2
  • \$\begingroup\$ It's not much, but in the even newer version of 05AB1E you can remove the ©, and change the ® to y to save a byte. \$\endgroup\$ Commented Apr 10, 2019 at 11:29
  • \$\begingroup\$ @KevinCruijssen Eh, I don't generally "update" old answers like that. Also, the "newer version" is a totally different language (different implementations). \$\endgroup\$ Commented Apr 10, 2019 at 18:08
1
\$\begingroup\$

Canvas, 20 bytes

9{R⤢x∙8∙+¹=¹◂±m) *]r

Try it here!

\$\endgroup\$
1
\$\begingroup\$

VBA (Excel), 51 bytes

Using Immediate Window

For z=1To 9:a=a &z:?Spc(9-z)a" x 8 +"z"="a*8+z:Next
\$\endgroup\$
0
\$\begingroup\$

k (77 bytes)

Could probably be shortened a bit more

-1@'((|t)#\:" "),'(t#\:n),'" x 8 + ",/:n,'" = ",/:(t:"I"$'n)#\:|n:"123456789";

Example:

k)-1@'((|t)#\:" "),'(t#\:n),'" x 8 + ",/:n,'" = ",/:(t:"I"$'n)#\:|n:"123456789";
         1 x 8 + 1 = 9
        12 x 8 + 2 = 98
       123 x 8 + 3 = 987
      1234 x 8 + 4 = 9876
     12345 x 8 + 5 = 98765
    123456 x 8 + 6 = 987654
   1234567 x 8 + 7 = 9876543
  12345678 x 8 + 8 = 98765432
 123456789 x 8 + 9 = 987654321
\$\endgroup\$
0
\$\begingroup\$

golflua, 56 characters

p=""~@i=1,9p=p..i; w(S.q("%9s x 8 + %d = "..p*8+i,p,i))$

Sample run:

bash-4.3$ golflua -e 'p=""~@i=1,9p=p..i; w(S.q("%9s x 8 + %d = "..p*8+i,p,i))$'
        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.