using Plots; pyplot()
function fac1(n)
o = r = BigInt(1)
if n < 0
throw(DomainError(n, "Please input a positive integer."))
return -1
elseif n in [0,1]
return 1
end
while n >= 2
r = n * r
n = n - 1
end
return r
end
N = 1:1:100
M = [fac1(n) for n in N]
plot(fontfamily=("Serif"),dpi=1024)
plot!(N,M,color="#00B4DC",label="Factorial")
跑了一下,M
里面的数确实是一直增大的,也没有负数,估计是 Plots
包有问题。
soga 多谢指教
Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: ArgumentError: At least one finite value must be provided to formatter.
Stacktrace:
[1] showoff(::Array{Float64,1}, ::Symbol) at /Users/ldnn97/.julia/packages/Showoff/0KxsS/src/Showoff.jl:106
Plot包里的showoff函数不支持那么大的数吧