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

how to check if list has consecutive powers

$
0
0

I am new to ruby and working on a problem but I don't know how to figure it out.I want to write a function that return true if each consecutive element is a power of the previous element, otherwise return false

for example: if I have a list [2;4;8;16] the function should return truefunction should return false , [3; 7; 9;]

let consec_ele element = match element with[] -> trueh::t -> if h > t then falseelse  if t/h = 0 && t mod h = 0 then true;;

i just can't figure out how to make it work and that so recursively.


Viewing all articles
Browse latest Browse all 527

Trending Articles



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