37 lines
800 B
Julia
Executable file
37 lines
800 B
Julia
Executable file
#!/usr/bin/env julia
|
|
|
|
# Jacek Poziemski 272389
|
|
|
|
"""
|
|
findsmallest(start::Float64, finish::Float64)
|
|
|
|
Find the smallest Float64 larger than `start`
|
|
and smaller than `finish` that satisfies the
|
|
following inequality `x * (1/x) ≠ 1`.
|
|
|
|
# Arguments
|
|
- `start::Float64`: bottom limit for the wanted number
|
|
- `finish::Float64`: upper limit for the wanted number
|
|
"""
|
|
function findsmallest(start::Float64, finish::Float64)
|
|
x = nextfloat(Float64(start))
|
|
res = zero(Float64)
|
|
|
|
while x < Float64(finish)
|
|
res = x * (one(Float64) / x)
|
|
if res != one(Float64)
|
|
return x
|
|
end
|
|
x = nextfloat(x)
|
|
end
|
|
|
|
return missing
|
|
end
|
|
|
|
smallest = findsmallest(1.0, 2.0)
|
|
|
|
if ismissing(smallest)
|
|
println("smallest not found")
|
|
else
|
|
println("smallest: $smallest")
|
|
end
|