-
Notifications
You must be signed in to change notification settings - Fork 0
lab03, Recursive and cycle functions #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
lab03/src/fibonacci.java
Outdated
| @@ -0,0 +1,21 @@ | |||
| public class fibonacci { | |||
|
|
|||
| int recursionExecute(int prev, int curr, int n, int stop){ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
дуже погана реалізація. Я таку вже бачив, один в один...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Перероблю інакше
| public int execute(int x, int y){ | ||
| if (y == 0) return x; | ||
|
|
||
| return execute(x ^ y, (x & y) << 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
і тут так само. Зможете мені пояснити на пальцях як цее працює? з усіма зсувами і логічними функціями?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я використовую x ^ y щоб скласти ці два значення, потім складаю це значення з x & y << 1 - для того щоб врахувати "перенесені біти" допоки x & y << 1 (перенесені біти) не будуть дорівнювати 0 (перенесених бітів немає)
lab03/src/factorial.java
Outdated
| @@ -0,0 +1,19 @@ | |||
| public class factorial { | |||
| int recursionExecute(int num, int n, int stop){ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
дуже погана реалізація. Я таку вже бачив, один в один...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добре, перероблю
8e022f0 to
46b2581
Compare
No description provided.