2017-02-26 3 views
0

Comme indiqué dans la documentation de Julia (avant 0.6), la factorisation en nombres premiers peut être effectuée en utilisant facteur (n).Factorisation initiale en julia 0.6

Cela ne fonctionne pas dans Julia 0.6. Existe-t-il un package dans les nouvelles versions de Julia qui affiche les facteurs premiers et leur arité pour un nombre donné n comme le montre le facteur (n) ci-dessous (dans la documentation)?

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 

Répondre

6

Ceci a été déplacé dans le paquet Primes.jl.

Un avertissement de dépréciation est fourni dans Julia v0.5, et la fonction est complètement supprimée dans 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 
+2

Y a-t-il un avertissement de dépréciation correspondant? –

+5

Il a été déplacé dans 0.5 et il y avait un avertissement de dépréciation. Cet avertissement a disparu en 0.6 depuis qu'il a été abandonné pour une version. Sauter des versions est dangereux :) – StefanKarpinski