reset password
Author Message
rabbott
Posts: 1649
Posted 18:14 Jan 30, 2019 |

A couple of suggestions to avoid some of Haskell's pickiness with numeric types.

1. Define iSqrt with round rather than floor: iSqrt n = round (sqrt (fromIntegral n)). round returns an Integer; floor returns a Float. Life is easier for us if iSqrt returns an Integer.

2. Use (g-p) `div` 2 rather than (g-p) / 2. Using / returns a Float; the function div does integer division, which is what we want.

With these changes iSqrt and isASquare deal strictly with integers, and your search will also deal strictly with integers. 

 

Last edited by rabbott at 19:24 Jan 30, 2019.
rabbott
Posts: 1649
Posted 21:49 Jan 30, 2019 |

Other than 5777 and 5993, no other counterexamples have been found. See: http://oeis.org/A060003. (But your program should be written to look for them anyway!)

Last edited by rabbott at 21:51 Jan 30, 2019.