Steady squares: Difference between revisions

Steady squares in Gambas
(Added Applesoft BASIC and MSX Basic)
(Steady squares in Gambas)
Line 349:
9376^2 = 87909376
</pre>
 
==={{header|Gambas}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vbnet">Public Sub Main()
For i As Integer = 1 To 10000
If is_steady_square(i) Then Print Format$(i, "####"); "^2 = "; Format$(i ^ 2, "########")
Next
End
 
Function numdig(n As Integer) As Integer
 
Dim d As Integer = 0
While n
d += 1
n \= 10
Wend
Return d
 
End Function
 
Function is_steady_square(n As Integer) As Boolean
 
Dim n2 As Integer = n ^ 2
Return IIf(n2 Mod CInt(10 ^ numdig(n)) = n, True, False)
 
End Function
</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|GW-BASIC}}===
2,122

edits