Find square difference: Difference between revisions
→OCaml: add
m (→{{header|J}}) |
(→OCaml: add) |
||
Line 77:
=={{header|Arturo}}==
<syntaxhighlight lang="rebol">i: new 1
while ø [
Line 122 ⟶ 121:
501
</pre>
=={{header|BASIC}}==
Line 279 ⟶ 277:
501
</pre>
=={{header|Factor}}==
The difference between squares is the odd numbers, so ls(n)=⌈n/2+1⌉.
Line 381 ⟶ 380:
501
</syntaxhighlight>
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let calculate x =
succ (succ x lsr 1)
let () =
Printf.printf "%u\n" (calculate 1000)</syntaxhighlight>
{{out}}
<pre>501</pre>
=={{header|Pari/GP}}==
Line 591 ⟶ 599:
=={{header|Quackery}}==
<syntaxhighlight lang="quackery"> [ dup * ] is squared ( n --> n )
Line 606 ⟶ 613:
==={{header|Using algebra}}===
Noting that a²-b² ≡ (a+b)(a-b), and that in this instance a = b+1.
|