// Performance test case for optimization analysis
fn fibonacci(n) {
if n <= 1 {
n
} else {
fibonacci(n - 1) + fibonacci(n - 2)
}
}
fn sum_range(start, end) {
let mut total = 0
for i in start..end {
total = total + i
}
total
}
fn nested_loops(n) {
let mut count = 0
for i in 0..n {
for j in 0..n {
count = count + 1
}
}
count
}
// Test recursive performance (exponential complexity)
let fib_result = fibonacci(20)
println("Fibonacci(20) = " + fib_result.to_string())
// Test loop performance
let sum_result = sum_range(1, 1000)
println("Sum 1-999 = " + sum_result.to_string())
// Test nested loop performance (O(n²))
let nested_result = nested_loops(100)
println("Nested loops 100x100 = " + nested_result.to_string())