public/subjects/collatzcountdown
Augusto cba96cfa4a Add link to the collatz conjecture 2021-09-17 14:50:44 +01:00
..
README.md Add link to the collatz conjecture 2021-09-17 14:50:44 +01:00

README.md

collatzcountdown

Instructions

Write a function, CollatzCountdown, that returns the number of steps necessary to reach 1 using the collatz countdown.

  • It must return -1 if start is equal to 0 or negative.

Expected function

func CollatzCountdown(start int) int {

}

Usage

Here is a possible program to test your function :

package main

import (
	"fmt"
	"piscine"
)

func main() {
	steps := piscine.CollatzCountdown(12)
	fmt.Println(steps)
}

And its output :

$ go run .
9
$