Skip to content

Conversation

@RostislavPorohnya
Copy link
Owner

No description provided.

@RostislavPorohnya RostislavPorohnya self-assigned this Dec 3, 2022
@@ -0,0 +1,21 @@
public class fibonacci {

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

Choose a reason for hiding this comment

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

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

Copy link
Owner Author

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);

Choose a reason for hiding this comment

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

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

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

@@ -0,0 +1,19 @@
public class factorial {
int recursionExecute(int num, int n, int stop){

Choose a reason for hiding this comment

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

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

Copy link
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.

3 participants