I am currently looking at project euler issues using Clojure. The second question requires you to summarize the first 400,000 fibonation numbers. Unfortunately, my code gives me an Integer Overflow exception.
(defn even-fib-sum [n] (reduce + (filter even? (take n (map first (iterate (fn [[x y]] [y (+ x y)]) [0 1]))))))
The problem occurs when I call a function and pass the value 4000000
(even-fib-sum 4000000) -> throws exception (even-fib-sum 40) -> 82790070
use +'instead +to get auto-update added to bigintegers
+'
+
(reduce +' (filter even? (take n (map first (iterate (fn [[x y]] [y (+' x y)]) [0 1])))))
Cloujure longs . , , , , , , , +', *' -', ,
*'
-'
Source: https://habr.com/ru/post/1569486/More articles:You must run the cron job in the Google compute engine (gce) to take a gcloud snapshot with the service account - cronValidation error handling in Ember.js - ember.jsRegex 5 Digit Numbers From Theme In MS Outlook - vbaСглаживание JToken - jsonUsing a digital signature to provide a QR code - javaIs there an alternative to LEFT JOIN in custom tables with WordPress? - phpQR Code Security - securityHow to run Gradle task after apks are created in Android Studio? - android-studioApache Spark: SparkPi example - apache-sparkHow to implement the LINQ extension of the MaxOrDefault extension (x => x.SomeInt)? - c #All Articles