Odd and square numbers: Difference between revisions
Content added Content deleted
(add OCaml) |
|||
Line 415: | Line 415: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<syntaxhighlight lang="julia">oddsquares(lim) = [i^2 for i ∈ Int.(range((√).(lim)...)) if isodd(i)] |
|||
{{trans|FreeBASIC}} |
|||
oddsquares((100, 999)) |
|||
<syntaxhighlight lang="julia">julia> i = n = 1 |
|||
1 |
|||
julia> while n < 1000 |
|||
n > 100 && println(n) |
|||
n += 8i |
|||
i += 1 |
|||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{Out}} |
|||
<pre> |
|||
11-element Vector{Int64}: |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</pre> |
|||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
||
<syntaxhighlight lang="mathematica">Cases[Range[100, 1000], _?(IntegerQ[Sqrt@#] && OddQ[#] &)]</syntaxhighlight> |
<syntaxhighlight lang="mathematica">Cases[Range[100, 1000], _?(IntegerQ[Sqrt@#] && OddQ[#] &)]</syntaxhighlight> |