Skip to content

lab03, Recursive and cycle functions - #3

Open
RostislavPorohnya wants to merge 1 commit into
mainfrom
lab03
Open

lab03, Recursive and cycle functions#3
RostislavPorohnya wants to merge 1 commit into
mainfrom
lab03

Conversation

@RostislavPorohnya

Copy link
Copy Markdown
Owner

No description provided.

@RostislavPorohnya RostislavPorohnya self-assigned this Dec 3, 2022
Comment thread lab03/src/fibonacci.java Outdated
@@ -0,0 +1,21 @@
public class fibonacci {

int recursionExecute(int prev, int curr, int n, int stop){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дуже погана реалізація. Я таку вже бачив, один в один...

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Перероблю інакше

Comment thread lab03/src/sum.java
public int execute(int x, int y){
if (y == 0) return x;

return execute(x ^ y, (x & y) << 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

і тут так само. Зможете мені пояснити на пальцях як цее працює? з усіма зсувами і логічними функціями?

Copy link
Copy Markdown
Owner Author

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 (перенесених бітів немає)

Comment thread lab03/src/factorial.java Outdated
@@ -0,0 +1,19 @@
public class factorial {
int recursionExecute(int num, int n, int stop){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дуже погана реалізація. Я таку вже бачив, один в один...

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добре, перероблю

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants