I want to learn a bit of OCaml, just to get a taste of a programming language other than C++ and Java. I will be very greatful if you help me with the following program: basically the user inputs a positive integer. The sum of all integers from N to 0 is printed.
Obviously you create an integer N
, let the user enter its value. Create a variable sum
of type int
. Have a for
loop which will add N
to sum
and then decrement N
's value by one. The loop will run while N
is greater than 1. I have no idea how to do this in OCaml's syntax though.
Any help would be highly appreciated.