Coding ASMR | solving recursion problems

Channel:
Subscribers:
1,200
Published on ● Video Link: https://www.youtube.com/watch?v=6sQv3j42gIM



Duration: 44:44
162 views
11


This is an ASMR styled coding video, where I code various things from problems to simple applications while giving you tingles.

In this video I do more recursion exercises. In the last video I have made my first recursive methods and in this video I have kind of gotten a grasp on this topic. I do two out of the three problems: one involved taking the sum from 1 to n, and another one to check if a number is prime or not, only using recursion instead of a loop.

While I managed to get the idea of calling functions recursively I am still new to it, and I feel there are better ways to solving it, like the better solution I came up with outside this video.

If you have gotten your tingles, a like would be appreciated!

previous video: https://youtu.be/Kn1py_jFXrE

//better way to recursively call it
public static int sumToN(int n) {

//condition should be if n is strictly greater than 0, cant use angle brackets
if (n > 0) {
//return the number added with the result of calling the function itself, which recursively calls itself until n is 0
return n + sumToN(n - 1);
}

return n;

}







Tags:
coding
programming
computer science
asmr java
asmr lofi
asmr typing
asmr coding
asmr programming
asmr java programming
asmr java recursion
asmr trying out recursion
asmr resursion
java trying out recursion
asmr solving java problems
asmr coding challenges
asmr solving recursion
asmr male
asmr tingles
Coding ASMR | solving recursion problems