Jump to content

Pascal's triangle/Puzzle: Difference between revisions

Pascal's triangle/Puzzle en FreeBASIC
m (→‎{{header|Phix}}: acutllay use that solveN(), syntax coloured, plus three alternatives)
(Pascal's triangle/Puzzle en FreeBASIC)
Line 1,274:
X = 5, Z = 8
</pre>
 
=={{header|FreeBASIC}}==
{{trans|PureBasic}}
<lang freebasic>Function SolveForZ(x As Integer) As Integer
Dim As Integer a, b, c, d, e, f, g, h, z
For z = 0 To 20
e = x + 11
f = 11 + (x+z)
g = (x+z) + 4
h = 4 + z
If e + f = 40 Then
c = f + g
d = g + h
a = 40 + c
b = c + d
If a + b = 151 Then Return z
End If
Next z
Return -1
End Function
 
Dim As Integer x = -1, z = 0
Do
x = x + 1
z = SolveForZ(x)
Loop Until z >= 0
 
Print "X ="; x
Print "Y ="; x + z
Print "Z ="; z
Sleep
</lang>
{{out}}
<pre>X = 5
Y = 13
Z = 8</pre>
 
 
=={{header|Go}}==
2,133

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.