SHARE
TWEET

Untitled

a guest Oct 14th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func prima() {
  8.     number := 123
  9.     sum := 0
  10.    
  11.     for number > 0 {
  12.         sum += number % 10
  13.         number /= 10
  14.     }
  15.    
  16.     fmt.Println(sum)
  17. }
  18.  
  19. func doua() {
  20.     n := 5
  21.     a,b,c := 0,1,0
  22.    
  23.     for i := 0; i < n; i++ {
  24.         c = a + b
  25.         fmt.Println(c)
  26.         a = b
  27.         b = c
  28.     }
  29. }
  30.  
  31. func treia() {
  32.     arr := [6]int{2, 3, 5, 7, 11, 13}
  33.     min,max := arr[0],arr[0]
  34.     for i := 0; i < len(arr); i++ {
  35.         if arr[i] < min {
  36.             min = arr[i]
  37.         }
  38.         if(arr[i] > max) {
  39.             max = arr[i]
  40.         }
  41.     }
  42.     fmt.Println(min)
  43.     fmt.Println(max)
  44. }
  45.  
  46. func patra() {
  47.     flag := true
  48.     arr := [6]int{2, -1, 5, 7, 11, 13}
  49.     for i := 0; i < len(arr) - 1; i++ {
  50.         if(arr[i+1] < arr[i]) {
  51.             flag = false
  52.         }
  53.     }
  54.     fmt.Println(flag)
  55. }
  56.  
  57. func main() {
  58.     prima()
  59.     doua()
  60.     treia()
  61.     patra()
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top