julia 0.6 中的质因数分解
Prime factorization in julia 0.6
如 Julia 的文档(0.6 之前)所述,可以使用 factor(n).
进行质因数分解
它在 Julia 0.6 中不起作用。新版本的 Julia 中是否有任何包输出素数及其对任何给定数字 n 的元数,因为 factor(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
这已移至程序包 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
运行: Pkg.add(素数)
Pkg.update() 更新全部
运行: 使用(Primes)编译包
因子(100)
- 运行
import Pkg; Pkg.add("Primes")
安装 primes 包。
如 Julia 的文档(0.6 之前)所述,可以使用 factor(n).
进行质因数分解它在 Julia 0.6 中不起作用。新版本的 Julia 中是否有任何包输出素数及其对任何给定数字 n 的元数,因为 factor(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
这已移至程序包 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
运行: Pkg.add(素数) Pkg.update() 更新全部
运行: 使用(Primes)编译包
因子(100)
- 运行
import Pkg; Pkg.add("Primes")
安装 primes 包。