正如Julia的文档(0.6之前)所述,素数分解可以通过使用因子(N)来完成。
它在Julia 0.6中不起作用。在新版本的Julia中是否有任何软件包可以输出任意给定数字的素数因子和它们的正则性,就像下面(文档中的)所示的(N)?
factor(n) → Dict
Compute the prime factorization of an integer n.
Returns a dictionary. The keys of the dictionary correspond to the factors, and hence are of the same type as n.
The value associated with each key indicates the number of times the factor appears in the factorization.
julia> factor(100) # == 2*2*5*5
Dict{Int64,Int64} with 2 entries:
2 => 2
5 => 2
发布于 2017-02-26 18:22:08
这被移到了Primes.jl包中。
Julia v0.5中提供了一个弃用警告,该函数在v0.6中被完全删除。
julia> VERSION
v"0.5.0"
julia> factor(100)
ERROR: factor(100,) has been moved to the package Primes.jl.
Run Pkg.add("Primes") to install Primes on Julia v0.5-
in factor(::Int64, ::Vararg{Int64,N}) at ./deprecated.jl:210
发布于 2018-12-18 05:08:59
运行:Pkg.add(素数) Pkg.update()以更新所有
运行:使用(Primes)编译包
系数(100)
发布于 2019-10-29 18:14:09
import Pkg; Pkg.add("Primes")
以安装primes软件包。https://stackoverflow.com/questions/42467136
复制相似问题