Mode:
Duration:
1
2
3
4
5
6
7
def factorial
factorial = { n ->
if (n <= 1) return 1
else return n * factorial(n-1)
}
println "Factorial of 5: ${factorial(5)}"Coding works best on desktop or with an external keyboard.
def factorial
factorial = { n ->
if (n <= 1) return 1
else return n * factorial(n-1)
}
println "Factorial of 5: ${factorial(5)}"Coding works best on desktop or with an external keyboard.
Recursive factorial function.
def factorial
factorial = { n ->
if (n <= 1) return 1
else return n * factorial(n-1)
}
println "Factorial of 5: ${factorial(5)}"Groovy is a powerful, dynamic JVM language that integrates seamlessly with Java, offering concise syntax, scripting capabilities, functional programming patterns, and strong support for automation, DSL creation, and Gradle build scripts. It blends Java familiarity with Python/Ruby-like expressiveness.
Origin & Creator
Created by James Strachan in 2003; later developed under the Apache Software Foundation.
Industrial Note
Groovy is foundational to Gradle and Jenkins pipelines. It dominates CI/CD automation, DevOps pipelines, JVM scripting, and domain-specific language (DSL) development across enterprises.