Categories
Go

Factorial Using Functions in Go

 A simple program that I wrote to solve a factorial value of a given number using a function and recursion concepts in go programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

Program Listing

/* function_recursion.go
Prof. Jake R. Pomperada, MAED-IT, MIT
www.jakerpomperada.com / www.jakerpomperada.blogspot.com
jakerpomperada@gmail.com
March 31, 2021  Saturday 10:18 PM
Bacolod City
*/

package main

import "fmt"

func factorial_solve(num int) int {
	if num == 1 || num == 0 {
		return num
	}
	return num * factorial_solve(num-1)
}

func main() {
	fmt.Printf("\n")
	fmt.Print("\tRecursion Using Function in Go\n\n")
	fmt.Printf("\t %d\n", factorial_solve(3))
	fmt.Printf("\t %d\n", factorial_solve(4))
	fmt.Printf("\t %d\n", factorial_solve(5))
	fmt.Printf("\t %d\n", factorial_solve(6))
	fmt.Printf("\t %d\n", factorial_solve(7))
	fmt.Printf("\n")
	fmt.Printf("\tEnd of Program")
	fmt.Printf("\n")
}
Categories
Go

Two Dimensional Arrays in Go

In this article I would like to share how to declare and use two-dimensional arrays using Go programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

Program Listing

package main

import "fmt"

func main() {
	/* An array with 3 rows and 3 columns
	   with initialize values
	*/
	var a = [3][3]int{{10, 20, 30}, {40, 50, 60}, {70, 80, 90}}

	var i, j int

	fmt.Print("\n")
	fmt.Print("\tExample of Two Dimensional Arrays in Go\n\n")
	/* output each array element's value */
	for i = 0; i < 3; i++ {
		for j = 0; j < 3; j++ {
			fmt.Printf("\ta[%d][%d] = %d\n", i, j, a[i][j])
		}
	}
	fmt.Print("\n\n")
	fmt.Print("\tEnd of Program")
	fmt.Print("\n")
}