Closed xenomorpheus closed 9 months ago
Hey, this repo is for www.rust-lang.org and your issue should go to https://github.com/rust-lang/rust-by-example. Thanks Manish for transferring :)
Hi, I'm closing this issue just to clean up the items that already exist. If you think this issue makes sense to stay open, please create a new issue with updated information and mention this one.
thanks!
What needs to be fixed?
Open to interpretation but "sum of all the squared odd numbers", but I would have thought the subject is the 'odd numbers' rather than 'odd squared numbers'.
So the test or filter is is_odd(n) rather than is_odd(n_squared)
Likewise the test being "if n >= upper {" rather than n_squared.
The test is_odd(n) to be done before the calculation of n_squared, thus reducing wasted effort.
Even if the interpretation is that is_odd(n_squared) is correct, in practice we would still do these changes as I believe the only way to get an odd square is to start with an odd. Though it is midnight in my timezone and it has been a long day.
Aside we could always add 2 to n rather than 1, because I don't believe any even n won't produce an odd square.
Page(s) Affected
https://doc.rust-lang.org/beta/rust-by-example/fn/hof.html
Suggested Improvement
And likewise for the functional