Pārlūkot izejas kodu

Fix variable naming

Adel Qalieh 9 gadi atpakaļ
vecāks
revīzija
a9571617a5
3 mainītis faili ar 15 papildinājumiem un 15 dzēšanām
  1. 7 7
      problem03.go
  2. 4 4
      problem04.go
  3. 4 4
      problem08.go

+ 7 - 7
problem03.go

@@ -3,21 +3,21 @@ package main
 import "fmt"
 
 func main() {
-	fmt.Println(max_prime_factor(13195))
-	fmt.Println(max_prime_factor(600851475143))
+	fmt.Println(maxPrimeFactor(13195))
+	fmt.Println(maxPrimeFactor(600851475143))
 }
 
-func max_prime_factor(n int) int {
-	var max_factor int
+func maxPrimeFactor(n int) int {
+	var maxFactor int
 	d := 2
 	for n > 1 {
 		for n%d == 0 {
-			if d > max_factor {
-				max_factor = d
+			if d > maxFactor {
+				maxFactor = d
 			}
 			n /= d
 		}
 		d++
 	}
-	return max_factor
+	return maxFactor
 }

+ 4 - 4
problem04.go

@@ -6,16 +6,16 @@ import (
 )
 
 func main() {
-	var max_palindrome int
+	var maxPalindrome int
 	for i := 0; i < 1000; i++ {
 		for j := i; j < 1000; j++ {
 			product := i * j
-			if palindrome(product) && product > max_palindrome {
-				max_palindrome = product
+			if palindrome(product) && product > maxPalindrome {
+				maxPalindrome = product
 			}
 		}
 	}
-	fmt.Println(max_palindrome)
+	fmt.Println(maxPalindrome)
 }
 
 func palindrome(n int) bool {

+ 4 - 4
problem08.go

@@ -9,14 +9,14 @@ const n = "731671765313306249192251196744265747423553491949349698352031277450632
 const l = 13
 
 func main() {
-	var max_product int
+	var maxProduct int
 	for i := 0; i < len(n)-l; i++ {
 		product := string_product(n[i : i+l])
-		if product > max_product {
-			max_product = product
+		if product > maxProduct {
+			maxProduct = product
 		}
 	}
-	fmt.Println(max_product)
+	fmt.Println(maxProduct)
 }
 
 func string_product(n string) int {