RosettaCodeData/Task/Babbage-problem/Scala/babbage-problem-1.scala

14 lines
355 B
Scala
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
object BabbageProblem {
def main( args:Array[String] ): Unit = {
2026-02-01 16:33:20 -08:00
2023-07-01 11:58:00 -04:00
var x : Int = 524 // Sqrt of 269696 = 519.something
2026-02-01 16:33:20 -08:00
2023-07-01 11:58:00 -04:00
while( (x * x) % 1000000 != 269696 ){
if( x % 10 == 4 ) x = x + 2
else x = x + 8
}
2026-02-01 16:33:20 -08:00
2023-07-01 11:58:00 -04:00
println("The smallest positive integer whose square ends in 269696 = " + x )
}
}