Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 591

why isn't my OCaml babbage program working?

$
0
0

code:

let babbage =   let n = read_int in  let current = ref n in  let square = ref !current in  let mul = !current * !current in  while ((square := mul) mod 1000000 != 269696) && (!square < max_int) do          current := !current + 1;  done;  if(!square > max_int) then    print_string "Condition not satisfied before max_int reached."  else print_string "The smallest number whose square ends in 269696 is"; !square

the error:

let mul = !current * !current in  Error: This expression has type unit -> int         but an expression was expected of type int         Hint: Did you forget to provide `()' as argument?

still learning but I wanted to really know what is wrong with it

EDIT #1: this is a practice exercise, and the type that is asked is unit -> int and it is given the function as let babbage () =


Viewing all articles
Browse latest Browse all 591

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>