Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
24
Task/Arithmetic-Rational/Julia/arithmetic-rational.julia
Normal file
24
Task/Arithmetic-Rational/Julia/arithmetic-rational.julia
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
function isperfect{T<:Integer}(n::T)
|
||||
!isprime(n) || return false
|
||||
tal = 1//n
|
||||
hi = isqrt(n)
|
||||
if hi^2 == n
|
||||
tal += 1//hi
|
||||
hi -= 1
|
||||
end
|
||||
for i in 2:hi
|
||||
(d, r) = divrem(n, i)
|
||||
if r == 0
|
||||
tal += (1//i + 1//d)
|
||||
end
|
||||
end
|
||||
return tal == 1//1
|
||||
end
|
||||
|
||||
lo = 2
|
||||
hi = 2^19
|
||||
println("Searching for perfect numbers from ", lo, " to ", hi, ".")
|
||||
for i in 2:2^19
|
||||
isperfect(i) || continue
|
||||
println(@sprintf("%8d", i))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue