RosettaCodeData/Task/Babbage-problem/PureBasic/babbage-problem.basic

22 lines
452 B
Plaintext

EnableExplicit
Macro putresult(n)
If OpenConsole("Babbage_problem")
PrintN("The smallest number whose square ends in 269696 is " + Str(n))
Input()
EndIf
EndMacro
CompilerIf #PB_Processor_x64
#MAXINT = 1 << 63 - 1
CompilerElseIf #PB_Processor_x86
#MAXINT = 1 << 31 - 1
CompilerEndIf
#GOAL = 269696
#DIV = 1000000
Define n.i, q.i = Int(Sqr(#MAXINT))
For n = 2 To q Step 2
If (n*n) % #DIV = #GOAL : putresult(n) : Break : EndIf
Next