Sha256: 8969afd101934805403bb4e5bd2bea6aa1096627b99f12df8f7ec2b806028b09

Contents?: true

Size: 351 Bytes

Versions: 154

Compression:

Stored size: 351 Bytes

Contents

exception NegativeInteger

fun steps number =
  let
    fun odd n = n mod 2 = 1

    fun steps' stepCount n =
      if n = 1
      then stepCount
      else if odd n
           then steps' (stepCount + 1) (3 * n + 1)
           else steps' (stepCount + 1) (n div 2)
  in
    if number > 0
    then steps' 0 number
    else raise NegativeInteger
  end

Version data entries

154 entries across 154 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.179 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.178 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.177 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.176 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.175 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.174 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.173 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.172 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.171 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.170 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.169 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.167 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.166 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.165 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.164 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.163 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.162 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.161 tracks/sml/exercises/collatz-conjecture/example.sml
trackler-2.2.1.160 tracks/sml/exercises/collatz-conjecture/example.sml