virtualx-engine/modules/gdscript/tests/scripts/runtime/features/recursion.gd
Hugo Locurcio c6ca09dc6f
Add more integration tests to the GDScript test suite
This also fixes a typo in the `bitwise_float_right_operand.gd` test.
2021-09-15 19:57:39 +02:00

19 lines
371 B
GDScript

func is_prime(number: int, divisor: int = 2) -> bool:
print(divisor)
if number <= 2:
return (number == 2)
elif number % divisor == 0:
return false
elif divisor * divisor > number:
return true
return is_prime(number, divisor + 1)
func test():
# Not a prime number.
print(is_prime(989))
print()
# Largest prime number below 10000.
print(is_prime(9973))