Projecteuler.net Problem 2 using collection pipeline Pattern I solve projecteuler.net Problem 2  deferent way

Generate number from 1 to range ex 100  and get the even number
Get Fibonacci numbers from list
Reduce array

I have one problem with a large set of numbers like 1000000 or 4000000.
can I ask how can I optimize the code? I am trying to solve the problem as a collection pipeline
swift code
var evenArray = ((0..&lt;100).filter({$0 % 2 == 0}))

print(evenArray)

var evenFibArray = evenArray.filter {(isPerfectSquare(5 * $0 * $0  + 4) || isPerfectSquare(5 * $0 * $0  - 4))}

print(evenFibArray)

var result  = evenFibArray.reduce(into: 0){$0 += $1}

print(result)


func isPerfectSquare(_ x:Int ) -&gt; Bool {
    let i = Int(sqrt(Double(x)))
    return  (i * i == x)
}
updated my code to use a deferent approach and apply collection pipeline
update my code

I use collection pipeline refactoring for more information about the
topics look
https://martinfowler.com/articles/refactoring-pipelines.html
I use stride function instead of filter to generate even Integer array

Sidenote: I don't know if I will save a couple of computing cycles—all I want to make my code more Swifty.
func isPerfectSquare(_ x:Int ) -&gt; Bool {
    let i = Int(sqrt(Double(x)))
    return  (i * i == x)
}

var result  =  (Array(stride(from: 0`enter code here`, to: 100, by: 2)).filter{(isPerfectSquare(5 * $0 * $0  + 4) || isPerfectSquare(5 * $0 * $0  - 4))}).reduce(into: 0){$0 += $1}
print(result)