A recursive function in VDM

380 Views Asked by At

How would I define a recursive function to find the biggest power of two less than an input number in VDM?

The function is as follows:

largest: N -> N

All I've got so far is:

largest(n) =

if n=1 then 0
else if n=2 then 1
else ... largest(...)

1

There are 1 best solutions below

0
On

It would be something like "else one plus the largest of half this number". But since this looks suspiciously like an exercise, I'll let you work out the fine details.