Skip to main content
Commonmark migration
Source Link

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected.

t:"Yfs

Try it online!

###Explanation

Explanation

t       % Take input (implicit). Duplicate
:"      % Do the following that many times
  Yf    %   Array of prime factors
  s     %   Sum of array
        % End (implicit). Display (implicit)

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected.

t:"Yfs

Try it online!

###Explanation

t       % Take input (implicit). Duplicate
:"      % Do the following that many times
  Yf    %   Array of prime factors
  s     %   Sum of array
        % End (implicit). Display (implicit)

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected.

t:"Yfs

Try it online!

Explanation

t       % Take input (implicit). Duplicate
:"      % Do the following that many times
  Yf    %   Array of prime factors
  s     %   Sum of array
        % End (implicit). Display (implicit)
added 239 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected.

t:"Yfs

Try it online!Try it online!

###Explanation

t       % Take input (implicit). Duplicate
:"      % Do the following that many times
  Yf    %   Array of prime factors
  s     %   Sum of array
        % End (implicit). Display (implicit)

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected

t:"Yfs

Try it online!

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected.

t:"Yfs

Try it online!

###Explanation

t       % Take input (implicit). Duplicate
:"      % Do the following that many times
  Yf    %   Array of prime factors
  s     %   Sum of array
        % End (implicit). Display (implicit)
Post Undeleted by Luis Mendo
deleted 499 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 76 bytes

`sYftnq

Try it online!

###ExplanationUses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected

`       % Do...while
  s     %   Sum of array. The first time it implicitly takes the input number,
        %   and its "sum" is that number. In subsequent iterations it sums the
        %   array of prime factors from the previous iteration
  Yf    %   Array of prime factors
  t     %   Duplicate
  n     %   Length
  q     %   Subtract 1
        % End (implicit). Proceeds with next iteration if the top of the stack
        % is non-zero, that is, if the latest array of prime factors had more
        % than one entry. Exits when that array contains a single number
        % Display stack (implicit):"Yfs

Try it online!

MATL, 7 bytes

`sYftnq

Try it online!

###Explanation

`       % Do...while
  s     %   Sum of array. The first time it implicitly takes the input number,
        %   and its "sum" is that number. In subsequent iterations it sums the
        %   array of prime factors from the previous iteration
  Yf    %   Array of prime factors
  t     %   Duplicate
  n     %   Length
  q     %   Subtract 1
        % End (implicit). Proceeds with next iteration if the top of the stack
        % is non-zero, that is, if the latest array of prime factors had more
        % than one entry. Exits when that array contains a single number
        % Display stack (implicit)

MATL, 6 bytes

Uses scottinet's idea of looping more times than needed. Thanks also to Shaggy for a pointing out a mistake, now corrected

t:"Yfs

Try it online!

Post Deleted by Luis Mendo
deleted 10 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading