k.go 292 B

12345678910111213141516171819202122
  1. package kata
  2. import "strconv"
  3. func fact(n int) int {
  4. if n <= 1 {
  5. return 1
  6. }
  7. return n * fact(n - 1)
  8. }
  9. func Strong(n int) string {
  10. s := strconv.Itoa(n)
  11. fSum := 0
  12. for _, r := range s {
  13. fSum += fact(int(r - '0'))
  14. }
  15. if fSum == n {
  16. return "STRONG!!!!"
  17. }
  18. return "Not Strong !!"
  19. }