Find square difference: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(add task to zig language)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(One intermediate revision by one other user not shown)
Line 553:
repeat
i += 1
squarea = pow i 2* i
diffSquareb = pow (i - 1) 2* (i - 1)
until differencea - b > 1000
difference = square - diffSquare
until difference > 1000
.
print i
Line 1,059 ⟶ 1,058:
=={{header|Wren}}==
The solution '''n''' for some non-negative integer '''k''' needs to be such that: ''n² - (n² - 2n + 1) > k'' which reduces to: ''n > (k + 1)/2''.
<syntaxhighlight lang="ecmascriptwren">var squareDiff = Fn.new { |k| ((k + 1) * 0.5).ceil }
System.print(squareDiff.call(1000))</syntaxhighlight>
 
9,476

edits