RosettaCodeData/Task/Babbage-problem/Microsoft-Small-Basic/babbage-problem.basic

26 lines
968 B
Plaintext

' Babbage problem
' The quote (') means a comment
' The equals sign (=) means assign
n = 500
' 500 is stored in variable n*n
' 500 because 500*500=250000 less than 269696
' The nitty-gritty is in the 3 lines between "While" and "EndWhile".
' So, we start with 500, n is being incremented by 1 at each round
' while its square (n*n) (* means multiplication) does not have
' a remainder (function Math.Remainder) of 269696 when divided by one million.
' This means that the loop will stop when the smallest positive integer
' whose square ends in 269696
' is found and stored in n.
' (<>) means "not equal to"
While Math.Remainder( n*n , 1000000 ) <> 269696
n = n + 1
EndWhile
' (TextWindow.WriteLine) displays the string to the monitor
' (+) concatenates strings or variables to be displayed
TextWindow.WriteLine("The smallest positive integer whose square ends in 269696 is " + (n) + ".")
TextWindow.WriteLine("Its square is " + (n*n) + ".")
' End of Program.