File: increment.go

package info (click to toggle)
delve 1.26.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 15,084 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (18 lines) | stat: -rw-r--r-- 230 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main

import "fmt"

// Increment Natural number y
func Increment(y uint) uint {
	if y == 0 {
		return 1
	}
	if y%2 == 1 {
		return (2 * Increment(y/2))
	}
	return y + 1
}

func main() {
	fmt.Printf("%d\n", Increment(3))
}