g | x | w | all
Bytes Lang Time Link
113Tcl180504T161520Zsergiol
038Juby230712T193954ZJordan
016APL Dyalog Unicode201223T203011ZKamila S
056Julia 0.6180702T151054ZSundar R
013Japt180504T152638ZShaggy
033Gol><>180514T005338ZBubbler
136Befunge180513T234348ZGegell
129Java 8180507T070614ZKevin Cr
057Ruby180504T201720ZKirill L
109R180504T144948Zngm
060Python 2180504T133309ZDennis
175F#180505T150301ZCiaran_M
008Gaia180504T142617ZMr. Xcod
018Charcoal180504T191813ZNeil
061Perl 5 p180504T210528ZXcali
093PowerShell Core180504T180524ZJeff Fre
049Perl 6180504T181728ZSean
7163Haskell180504T144208ZAngs
010Stax180504T133436ZMulti
00705AB1E180504T135948ZEmigna
089PHP 7180504T152839ZTitus
060JavaScript ES6180504T131824ZArnauld
011Pyth180504T142252ZMr. Xcod
013MATL180504T132922ZStewie G
007Husk180504T133104ZErik the
008Jelly180504T130605ZErik the

Tcl, 113 bytes

proc S n {set r [expr $n*($n+1)/2]
while \$r>9 {set r [join [split [expr [join [split $r ""] *]] ""] +]}
expr $r}

Try it online!

J-uby, 38 bytes

This is me resisting forking J-uby to add a bunch of single-character aliases for useful functions.

:+|:sum|:!~&((d=:digits)|:/&:*|d|:sum)

Attempt This Online!

Explanation

:+ | :sum | :!~ & ((d = :digits) | :/ & :* | d | :sum)

:+ | :sum |                                             # Range 1..n, then sum, then
            :!~ & (                                  )  # Until a fixed point is reached...
                  ((d = :digits) |                      #   Get digits (while saving the function to d for later), then
                                   :/ & :* |            #   Reduce with product, then
                                             d | :sum   #   Get digits, then sum

APL (Dyalog Unicode), 16 bytes

-4 thanks to @user

f←{⍎¨⍕×/⍎¨⍕+/⍵}⍣≡⍳

Try it online!

Julia 0.6, 56 bytes

f(n,k=(n+1)n÷2)=k>9?f(0,sum(digits(prod(digits(k))))):k

Try it online!

Pretty straightforward: calculate (n+1)n÷2 for sum from 1..n, check if it's a single digit number (>9), if it's not, try again with k set to the sum of the digits of the product of the digits of k, else return k.

Japt, 16 14 13 bytes

_ì ×ìx}gN®õ x

Try it


Explanation

                  :Implicit input of integer U
         ®        :Map
        N         :The array of inputs (which just contains U)
          õ       :  Range [1,U]
            x     :  Reduce by addition
_     }g          :Take the last element of N, run it through the following function and push the result to N
                  : Repeat U times and then return the last element of N
 ì                :  Split to an array of digits
   ×              :  Reduce by multiplication
    ìx            :  Split to an array of digits and reduce by addition

Gol><>, 35 33 bytes

1AY:P*2,TYMR*YR+:a(?Bt
:a(qlBaSD$

Try it online!

-2 bytes by Jo King.

Extensive use of functions and implicit infinite loops.

Example full program & How it works

1AGIE;GN
2AY:P*2,YlMR*YlR+:a(?B8R!
:a(?BaSD$

<main program>
1AG       Register row 1 as function G
   IE;    Take number input; halt on EOF
      GN  Call G and print the result as number
          Repeat indefinitely

<function G>
2AY            Register row 2 as function Y
   :P*2,       Sum of 1 to n
        Y      Call Y (break into digits)
         lMR*  Product
Y              Call Y
 lR+           Sum (an implicit zero is used)
    :a(?B      Return if the result is less than 10
         8R!   Skip initial 8 commands
               Repeat indefinitely

<function Y>
:a(?B      Return if the top is less than 10
     aSD   Divmod by 10; [... n] => [... n/10 n%10]
        $  Swap top two, so the "div" goes to the top

Befunge, 136 bytes

101p&::*+2/>:82+%01g*01p82+/:#v_$01gv
X      v_v# #:/+82p10+g10%+82: <p100<
v:g10$ >#<#^                 #<^
>82+/#v_.@
      >101p^

You can try it here.

While not all interpreters have a large enough cell size, it works with small numbers for pretty much anyone out there. For a larger number of n you might need a interpreter like BefunExec.

Java 8, 129 bytes

n->{long r=1,i=n;for(;i>1;r+=i--);for(;r>9;r=(i+"").chars().map(p->p-48).sum(),i=1)for(int s:(r+"").getBytes())i*=s-48;return r;}

Try it online.

Explanation:

n->{            // Method with integer parameter and long return-type
  long r=1,     //  Result-long, starting at 1
       i=n;     //  Temp integer, starting at the input `n`
  for(;i>1;     //  Loop as long as `i` is not 1 yet
      r+=i--);  //   And increase `r` by `i`
  for(;r>9      //  Loop as long as `r` is not a single digit yet
      ;         //    After every iteration:
       r=(i+"").chars().map(p->p-48).sum(),
                //     Set `r` to the sum of digits of `i`
       i=1)     //     And reset `i` to 1
    for(int s:(r+"").getBytes())i*=s-48;
                //    Set `i` to the product of the digits of `r`
  return r;}    //  Return `r` as result

Ruby, 57 bytes

->n{("*+"*n).chars.reduce(-~n*n/2){|x,y|eval x.digits*y}}

Try it online!

R, 152 130 109 bytes

function(w,x=w*(w+1)/2,y=prod(d(x)),z=sum(d(y)))"if"(z>9,f(,z),z)
d=function(x)x%/%10^(0:max(0,log10(x)))%%10

Try it online!

@Giuseppe found 21 42 bytes with various R things I'm not used to yet, along with a way to get the digits of a number without coercing to string and back, and with fewer bytes!

# Old
d=function(x)strtoi(el(strsplit(paste(x),"")))
# New
d=function(x)x%/%10^(0:max(0,log10(x)))%%10

options(scipen=9) is was required for the case of 9854 for the old function, because the first product stage ends up as 80000, which R prints as 8e+05.

Python 2, 77 72 71 62 60 bytes

lambda n:reduce(lambda x,c:eval(c.join(`x`)),'*+'*n,-n*~n/2)

Thanks to @xnor for golfing off 2 bytes!

Try it online!

F#, 175 bytes

let d n=seq{for i in(string n).ToCharArray() do yield string i|>uint64}
let c n=
 let mutable r=Seq.sum{1UL..n}
 while r>9UL do r<-d r|>Seq.reduce(fun a x->x*a)|>d|>Seq.sum
 r

Try it online!

The only caveat to the function is that the input value must be of type uint64.

Ungolfed it's a little like this:

let d n=seq{for i in(string n).ToCharArray() do yield string i|>uint64}

let c n =
 let mutable r = Seq.sum {1UL..n}
 while r > 9UL do
  r<-d r
  |> Seq.reduce(fun a x->x*a)
  |> d
  |> Seq.sum
 r

The function d n converts the number n into its component digits. It first converts to a string, then gets each character in the string. Each character must then be converted back into a string, otherwise the characters will be converted to their ASCII values instead of their "real" values.

The c n function is the main function, with n as the initial value. In this function r is our running value. The while loop does the following:

Gaia, 8 bytes

┅⟨Σ₸∨Π⟩°

Try it online!

The old explanation (before fixing a bug that is Gaia’s fault IMO :P):

┅⟨ΣΠ⟩° – Full program. N = The input.
┅      – Range. Push [1, N] ⋂ ℤ to the stack.
 ⟨  ⟩° – While no two consecutive iterations yield the same result, do:
  Σ    – Sum (or digital sum, when applied to an integer).
   Π   – Digital product.

Saved 1 byte thanks to Dennis.

Charcoal, 18 bytes

≔Σ…·¹NθW›θ⁹≔ΣΠθθIθ

Try it online! Link is to verbose version of code. Explanation:

≔Σ…·¹Nθ

Sum the integers up to the input.

 W›θ⁹≔ΣΠθθ

While the result is greater than 9, take the sum of digits of the product of digits.

Iθ

Cast the result to string and implicitly print it.

Perl 5 -p, 61 bytes

$_*=$_/2+.5;$_=eval((eval s/./$&*/gr.1)=~s/./+$&/gr)while$_>9

Try it online!

PowerShell Core, 91 101 93 bytes

Function F($a){$o=$a*($a+1)/2;1,2|%{$o=[char[]]"$([char[]]"$o"-join'*'|iex)"-join'+'|iex};$o}

Try it online!

Ungolfed a little...

Function F ($a)
{
    $o=$a*($a+1)/2;
    1..2 | % {
        $o = [char[]]"$o"-join '*' | iex;
        $o = [char[]]"$o"-join '+' | iex;
    }
    $o | Write-Output
}

First steps were to split the integers into digits -- did this by splitting the integer into an array of stringscharacters. Afterwards, insert the operand, and then evaluate the string as a command. Then, it's a matter of doing the multiple-add cycle until the input is one digit.

iex is an alias for Invoke-Command which evaluates a string passed into the first param position.

Edit: As requested by @AdmBorkBork, I have added a function header to the byte count. Also, I did a little math and realized that an upper bound on the number of iterations is < log log 10^6 < log 6 < 2, so that saved another six bytes.

Edit x2: @AdmBorkBork found a more terse way of converting the integer into a math expression, and then suggested piping it into iex. This saved 8 bytes. Thank you!

Perl 6, 49 bytes

{($_*.succ/2,{[+] ([*] .comb).comb}...9>=*).tail}

Try it online!

Haskell, 72 71 63 bytes

g=map(read.pure).show
f n=until(<10)(sum.g.product.g)$sum[1..n]

Thanks to @BMO for a byte and @nimi for 8 bytes!

Try it online!

Stax, 14 13 10 bytes

ñu┌↕a√äJ²┐

Run and debug it

Was pretty fun to make. I wonder if there is a more concise way to do the comparison at the end.

Explanation

|+wE:*E|+c9>                 # Full Program Unpacked
|+                           # Create range and sum it
   wE:*                      # Start loop, digitize number, product of digits
       E|+                   # Digitize number, sum digits
          c9>                # Duplicate, check length is = 1
                             # Otherwise loop back to the 'w' character

-1 bytes thanks to ovs

-3 bytes thanks to Scrooble

05AB1E, 7 bytes

LOΔSPSO

Try it online!

Exlpanation

L         # push range [1 ... input]
 O        # sum range
  Δ       # loop until top of stack stops changing
   SP     # product of digits
     SO   # sum of digits

PHP 7, 89 bytes

for($a=$argn*-~+$argn/2;$a>9;)$a=array_sum(($s=str_split)(array_product($s($a))));echo$a;

Run as pipe with -r or try it online.

JavaScript (ES6), 60 bytes

f=(n,k=n*++n/2)=>k>9?f(!n,eval([...k+''].join('*+'[+!n]))):k

Try it online!

Commented

f = (                     // f = recursive function taking:
  n,                      //   n = original input
  k = n * ++n / 2         //   k = current value, initialized to sum(i=1..n)(i)
) =>                      //
  k > 9 ?                 // if k has more than 1 digit:
    f(                    //   recursive call to f() with:
      !n,                 //     a logical NOT applied to n
      eval(               //     the result of the expression built by:
        [...k + '']       //       turning k into a list of digits
        .join('*+'[+!n])  //       joining with '*' on even iterations or '+' on odd ones
      )                   //     end of eval()
    )                     //   end of recursive call
  :                       // else:
    k                     //   stop recursion and return the last value

Alternate version, 59 bytes (non-competing)

A non-recursive version that only works for n < 236172. (It covers the requested range but does not qualify as a valid generic algorithm.)

n=>[...'*+*+'].map(o=>n=eval([...n+''].join(o)),n*=++n/2)|n

Try it online!

Pyth, 11 bytes

usj*FjGTTsS

Try it here!

usj*FjGTTsS – Full program. N = The input.
          S – Range. Yield [1, N] ⋂ ℤ.
         s  – Sum.
u           – While no two consecutive iterations yield the same result, do (var: G):
   *FjGT    – Digital product.
 sj     T   – Digital sum.

MATL, 15 13 bytes

In tribute to the Language of the month:

:`sV!UpV!Utnq

Try it online!

I don't think there's a simpler way to get the digits of a number than to convert the number to a string V, then transposing it !, and converting this vertical vector back to a numeric one U.

Saved 2 bytes thanks to the Creator1 himself! I forgot the implicit end, meaning I could remove ], and instead of comparing the number of elements with 1, I could simply decrement that value and use it as a boolean directly.

So, the explanation goes like this:

                 % Grab input n implicitly
:                % Range from 1 ... n inclusive
 `               % Do ... while
  s               % sum the vector
   V!U            % Convert the number to digits
      p           % Take the product of these digits
       V!U        % Convert the product into digits
          t       % Duplicate the result
           n      % Count the number of elements
            q     % Decrement the number of elements
                  % Loop until the number of elements is 1
                 % Implicit end

1... of MATL, Luis Mendo.

Husk, 7 bytes

ωöΣdΠdΣ

Try it online!

Jelly, 8 bytes

RSDPDƲÐL

Try it online!

Full program (it returns a singleton array containing the result, but the brackets aren't visible in STDOUT).