diff --git "a/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/README.md" "b/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/README.md" index 7d38e46f39ac0..d60943d259517 100644 --- "a/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/README.md" +++ "b/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/README.md" @@ -177,6 +177,25 @@ public class Solution { } ``` +#### Swift + +```swift +class Solution { + func fib(_ n: Int) -> Int { + var a = 0 + var b = 1 + var count = n + while count > 0 { + let c = (a + b) % 1000000007 + a = b + b = c + count -= 1 + } + return a + } +} +``` + diff --git "a/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/Solution.swift" "b/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/Solution.swift" new file mode 100644 index 0000000000000..29af382ba2350 --- /dev/null +++ "b/lcof/\351\235\242\350\257\225\351\242\23010- I. \346\226\220\346\263\242\351\202\243\345\245\221\346\225\260\345\210\227/Solution.swift" @@ -0,0 +1,14 @@ +class Solution { + func fib(_ n: Int) -> Int { + var a = 0 + var b = 1 + var count = n + while count > 0 { + let c = (a + b) % 1000000007 + a = b + b = c + count -= 1 + } + return a + } +} \ No newline at end of file