| 
									
										
										
										
											2018-10-13 23:30:21 +03:00
										 |  |  | // For more tutorials: https://blog.learngoprogramming.com | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Copyright © 2018 Inanc Gumus | 
					
						
							|  |  |  | // Learn Go Programming Course | 
					
						
							|  |  |  | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 	"strconv" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							| 
									
										
										
										
											2019-02-14 20:55:08 +08:00
										 |  |  | 	if len(os.Args) != 3 { | 
					
						
							| 
									
										
										
										
											2018-10-13 23:30:21 +03:00
										 |  |  | 		fmt.Println("gimme two numbers") | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	min, err1 := strconv.Atoi(os.Args[1]) | 
					
						
							|  |  |  | 	max, err2 := strconv.Atoi(os.Args[2]) | 
					
						
							|  |  |  | 	if err1 != nil || err2 != nil || min >= max { | 
					
						
							|  |  |  | 		fmt.Println("wrong numbers") | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var sum int | 
					
						
							|  |  |  | 	for i := min; i <= max; i++ { | 
					
						
							|  |  |  | 		sum += i | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		fmt.Print(i) | 
					
						
							| 
									
										
										
										
											2018-11-21 11:42:33 +03:00
										 |  |  | 		if i < max { | 
					
						
							| 
									
										
										
										
											2018-10-13 23:30:21 +03:00
										 |  |  | 			fmt.Print(" + ") | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	fmt.Printf(" = %d\n", sum) | 
					
						
							|  |  |  | } |