# HoI4 Babylonian (Newton) method of finding square roots by Yard1
```
# Babylonian (Newton) method of finding square roots by Yard1
# Feel free to use and modify provided credits are given
# # Finding the square root of 10.
# set_variable = { sr_arg_number = 10 } # Put 10 into the argument variable
# square_root_number = yes # Run the effect
# set_variable = { out = sr_ret_number } # Set your out variable to the return variable
# Square roots a number (sr_arg_number), returns value in sr_ret_number.
square_root_babylonian = {
if = {
limit = {
check_variable = { sr_arg_number < 0.001 }
}
set_variable = { sr_ret_number = 0 }
}
else = {
# overflow at 2147483.647
# therefore, highest possible square root * 2 is ~2931
set_temp_variable = { x = 2931 }
set_temp_variable = { y = 1 }
set_temp_variable = { e = 0.001 } # precision - game can't go any lower than this
while_loop_effect = {
limit = {
set_temp_variable = { t_x = x }
subtract_from_temp_variable = { t_x = y }
check_variable = { t_x > e }
}
add_to_temp_variable = { x = y }
divide_temp_variable = { x = 2 }
set_temp_variable = { y = sr_arg_number }
divide_temp_variable = { y = x }
}
set_variable = { sr_ret_number = x }
}
}
```