From aed37bf95375077f75fb72e2c384fbd1bda43dd6 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 24 Nov 2023 14:22:03 +0100 Subject: [PATCH] vault backup: 2023-11-24 14:22:03 --- .obsidian/workspace.json | 10 ++++---- Algo/B2/Exercises/Repetitive tutorial.md | 32 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 80b1455..09dbf15 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -13,7 +13,7 @@ "state": { "type": "markdown", "state": { - "file": "Prog/Collections.md", + "file": "Algo/B2/Exercises/Repetitive tutorial.md", "mode": "source", "source": false } @@ -85,7 +85,7 @@ "state": { "type": "backlink", "state": { - "file": "Prog/Collections.md", + "file": "Algo/B2/Exercises/Repetitive tutorial.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -102,7 +102,7 @@ "state": { "type": "outgoing-link", "state": { - "file": "Prog/Collections.md", + "file": "Algo/B2/Exercises/Repetitive tutorial.md", "linksCollapsed": false, "unlinkedCollapsed": true } @@ -125,7 +125,7 @@ "state": { "type": "outline", "state": { - "file": "Prog/Collections.md" + "file": "Algo/B2/Exercises/Repetitive tutorial.md" } } }, @@ -156,7 +156,7 @@ "command-palette:Open command palette": false } }, - "active": "41ec48cdc3af71a1", + "active": "c473a791e2b34194", "lastOpenFiles": [ "Prog/Collections.md", "Algo/B2/Exercises/Repetitive tutorial.md", diff --git a/Algo/B2/Exercises/Repetitive tutorial.md b/Algo/B2/Exercises/Repetitive tutorial.md index aa1311b..86727b9 100644 --- a/Algo/B2/Exercises/Repetitive tutorial.md +++ b/Algo/B2/Exercises/Repetitive tutorial.md @@ -72,3 +72,35 @@ def power(x, n): n -= 1 return res ``` + +## Exercise 1.4 + +```python +def fibo(n: int) -> int: + a = 0 + b = 1 + c = 0 + i = 2 + while i <= n: + c = a + b + a = b + b = c + i += 1 + return b +``` + +## Exercise 1.5 +```python +def my_sum(n: int) -> int: + s = 0 + i = 1 + while i <= n: + s += u(i) + i += 1 + return s +def my_sum(n: int) -> int: + s = 0 + while n > 0: + s += u(n) + n -= 1 + return s