Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Algorithm Go-lang Added #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Golang Algorithm/ArmstrongNumber.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//Program to check armstrong number

package main

import "fmt"

func main() {
var number, tempNumber, remainder int //declaring variables for execution
var result int = 0

fmt.Print("Enter a number to be checked: ")
fmt.Scan(&number)

tempNumber = number

//executing the logic for checking an armstrong number
for {
remainder = tempNumber % 10
result += remainder * remainder * remainder
tempNumber /= 10

if tempNumber == 0 {
break
}
}

if result == number {
fmt.Printf("%d is an Armstrong number.", number)
} else {
fmt.Printf("%d is not an armstrong number.", number)
}
}