# 顺序乘法

12

``````f(0) = a
f(n+1) = f(n)*(f(n)-1)
``````

13

# 果冻，3个字节

``````×’\$
``````

### 怎么运行的

``````×’\$    Main link (or part thereof). Argument (initially input): n

’     Compute n - 1.
×      Multiply n by (n - 1).
``````

4

## 认真地，4个字节

``````,;D*
``````

``````,;D*
,     push input (NOP once input is exhausted)
;D   dupe and push n-1
*  multiply
(implicit output at EOF)
``````

4

# MATL，3个字节

``````tq*
``````

4

## Python 3，56个字节

``````+1if 0else 0
try:n
except:n=int(input())
n*=n-1
print(n)``````

@Seadrus不，语法荧光笔与Python解析器不匹配，Python解析器在碰到`if`和时停止解析数字`else`
xnor

@ mbomb007不能完全正常工作，无法正确处理打印内容，并且至少连接一次时会得到额外的输出。
FryAmTheEggman '16

mbomb007 '16

3

# CJam，5个字节

``````r~_(*
``````

### 怎么运行的

``````r     e# Read a whitespace-separated token from STDIN.
e# This pushes the input (when called for the first time) or an empty string.
~    e# Evaluate.
e# This turns the input into an integer or discards an empty string.
_   e# Copy the top of the stack.
(  e# Decrement.
* e# Multiply.
``````

3

# pl，5个字节

``````_▼•=_
``````

## 说明

``````_▼•=_

_       push _ (input var)
▼      decrement last used var (_)
•     multiply, since it is off by one it auto-adds _ to the arg list
=_   assign result to _
``````

2

# 05AB1E，3个字节

``````D<*
``````

``````D    # Duplicate top of the stack, or input when empty
<   # Decrement on top item
*  # Multiply
``````

2

# GolfScript，5个字节

``````~.(*`
``````

``````~    # Eval the input to turn it from a string into a number.
.    # Duplicate the number.
(    # Decrement one of the copies by one.
*    # Multiply the copies together.
`    # Un-eval the number, turning it back into a string.
``````

GolfScript解释器会自动读取输入并将其放置在堆栈中，但以字符串形式而不是数字形式。因此，我们需要使用将输入转换为数字`~`，然后使用再次对其进行字符串化```。最后，解释器将自动在堆栈上打印出字符串化的数字。

（现在，如果挑战是要迭代`f(n+1) = f(n)*(-f(n)-1)`，我可以用4个字节来完成`~.~*`。弄清楚该方法的工作方式和原因作为练习。）

2

# JavaScript REPL，25个 20字节

``````a=prompt();
a*=a-1//
``````

Conor O'Brien

Conor O'Brien

2

2

## Lua，35 18字节

Lua可以轻松完成一次该操作！

``print(...*(...-1))``

`...`包含已解压缩的命令行参数，内联它将在此情况下使用其第一个值，因为它将不被允许消耗，从而导致print `n*(n-1)`

1

# Y，7个字节

``````jzC:t*!
``````

1

# Jolf，6个字节

``````oj*jwj
``````

## 说明

``````oj*jwj
oj      set j to
*jwj  j times j-1
implicit output
``````

1

# 𝔼𝕊𝕄𝕚𝕟，5个字符/ 7个字节

``````ï×‡ï;
``````

Try it here (Firefox only).

1

# Perl，23个字节

``````l;\$_|=<>;\$_*=~-\$_;print
``````

### 备用版本，10字节

``````\$_*=~-\$_;
``````

1

``````(*)=<<pred\$
``````

``````Prelude> (*)=<<pred\$5
20
Prelude> (*)=<<pred\$(*)=<<pred\$5
380
Prelude> (*)=<<pred\$(*)=<<pred\$(*)=<<pred\$5
144020
``````

`(*)=<<pred\$`节省3个字节。另外，应该注意，这实际上并没有定义一个函数，并且输入值必须直接放在它之后。
Zgarb '16

@Zgarb：谢谢！添加`id`使其具有适当的功能。我已经在回答中写了笔记。
nimi

1

# 纯bash（无实用程序），40

``````((a=a?a:\$1,a*=a-1))
trap 'echo \$a' exit
``````

1

# TI基本（6 5个字节）

``````:Ans²-Ans
``````

1
5字节：`:Ans²-Ans`
lirtosiast，2016年

1

0

``````(\x->if odd x then let y=until((>x).(10^))(+1)0 in y*(y-1)else x*(x-1))\$
``````

0

# C ++（gcc），173/176字节

## 宏版本，173字节

``````#ifndef M
#define M(a,b)a##b
#define W(z,x)M(z,x)
#define B int W(m,__LINE__)=x++
#include<iostream>
int x,n;int main(){for(std::cin>>n;x--;)n*=n-1;std::cout<<n;}
#endif
B;
``````

## 模板版本，176个字节

``````#ifndef B
#define B template
#include<iostream>
int x,n;B<int N>struct A{static int i;};int main(){for(std::cin>>n;x--;)n*=n-1;std::cout<<n;}
#endif
B<>int A<__LINE__>::i=x++;
``````

0

## 滑稽-5字节

``````J?d?*

blsq ) 5 J?d?*
20
blsq ) 5 J?d?* J?d?*
380
blsq ) 5 J?d?* J?d?* J?d?*
144020
``````