Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
R中是否有整数分区的实现?
例如对于输入 4,我想得到 5 个向量:
4 3 , 1 2 , 2 2 , 1 , 1 1 , 1 , 1 , 1
Python、Erlang、Java、C、Perl中有实现,但我在 R 中找不到任何东西。
使用“分区”包:
install.packages("partitions") library(partitions) parts(4) # # [1,] 4 3 2 2 1 # [2,] 0 1 2 1 1 # [3,] 0 0 0 1 1 # [4,] 0 0 0 0 1