Skip to content

Instantly share code, notes, and snippets.

@oriapp
Last active January 18, 2022 13:50
Show Gist options
  • Save oriapp/1aabc1d3e825016d943fae903e24c9d4 to your computer and use it in GitHub Desktop.
Save oriapp/1aabc1d3e825016d943fae903e24c9d4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
/*
Rules:
if the number is odd -> multiply by three and add 1 (one)
if the number is even -> divide by 2 (two)
*/
func main() {
startPoint := 7
for {
startPoint = RuleChecker(startPoint)
fmt.Println(startPoint)
time.Sleep(time.Second)
}
}
func RuleChecker(number int) int {
if number%2 != 0 {
return (number * 3) + 1
}
return number / 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment