In [ ]:
function sol3(tar::Int)
    n :: Int, i :: Int, cur :: Int = tar,3,tar
    while true

In [2]:
function odd_prime(n::Int)
    for i = 3:2:isqrt(n)
        if 0 == rem(n,i)
            return false
        end
    end
    return true
end


Out[2]:
odd_prime (generic function with 1 method)

In [24]:
function sol174(lim :: Int) 
    ctr :: Array{Int,1} = zeros(Int,lim)
    res :: Int = 0
    i :: Int = 1
    while true 
        isqr :: Int = i*i 
        tmp :: Int = (i+2)^2-isqr
        if tmp > lim 
            break
        else
            j :: Int = i+2
            jsqr :: Int = j*j
            jtmp :: Int = jsqr-isqr
            while true 
                if jtmp > lim 
                    break
                else
                    ctr[jtmp] += 1
                    j += 2
                    jsqr = j*j
                    jtmp = jsqr-isqr
                end
            end
            i += 1
        end
    end
    for k = 4:4:lim 
        m :: Int = ctr[k]
        if 1 <= m && m <= 10 
            res += 1
        end
    end
    return res
end


Out[24]:
sol174 (generic function with 1 method)

In [14]:
map(x -> x^2 - 16, 6:2:30)


Out[14]:
13-element Array{Int64,1}:
  20
  48
  84
 128
 180
 240
 308
 384
 468
 560
 660
 768
 884

In [12]:
@time sol173(1000000)


  
Out[12]:
1572729
 2.155 milliseconds (5 allocations: 160 bytes)

In [10]:
function sol173(lim :: Int) 
    res :: Int = 0
    i :: Int = 1
    while true 
        isqr :: Int = i*i 
        tmp :: Int = (i+2)^2-isqr
        if tmp > lim 
            return res 
        else
            j :: Int = i+2
            jsqr :: Int = j*j
            while true 
                if jsqr-isqr > lim 
                    break
                else
                    res += 1
                    j += 2
                    jsqr = j*j
                end
            end
            i += 1
        end
    end
end


Out[10]:
sol173 (generic function with 1 method)