This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(tailrecursion). | |
| -export([loop/1, fib/1, perfect/1, test_perfect_number/0, test_fib/0]). | |
| loop(N) when N > 0 -> | |
| io:format("~p~n", [N]), | |
| loop(N-1); | |
| loop(_N) -> | |
| io:format("bye ~n"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(week2_perfect_number). | |
| -export([perfectNumber/1]). | |
| -author("Pradeep Pillai"). | |
| perfectNumber(N) -> | |
| A = doPerfect(N, N div 2, []), | |
| N == lists:sum(A). | |
| doPerfect(_, 0, Result) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(fibandcuts). | |
| -export([factorial/1, fibonacci/1, pieces/1]). | |
| -export([test_pieces/0,test_fibonacci/0]). | |
| -author("Pradeep Pillai"). | |
| %Factorial of N | |
| %1 * 2 * 3 * (N-1) | |
| %Factorial of 0 is 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(week1). | |
| -export([xOr_first_impl/2, xOr_second_impl/2, xOr_third_impl/2, maxThree/3, howManyEqual/3 | |
| , test_howManyEqual_function/0, test_maxThree_function/0, test_xOrImpl_function/0]). | |
| %xOr implementations. | |
| xOr_first_impl(A, B) -> | |
| A =/= B. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(second). | |
| -import(first, [squareValue/1]). | |
| -export([sizeOfHypotenuse/2, perimeterOfRightAngledTriangle/2, areaOfTriangle/2]). | |
| %%below functions to be used for right angled triangle | |
| %returns the hypotenuse | |
| sizeOfHypotenuse(SideOne, SideTwo) -> | |
| math:sqrt(squareValue(SideOne) + squareValue(SideTwo)). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(first). | |
| -export([double/1, mult/2, area/3, squareValue/1, tripleValue/1]). | |
| mult(X, Y) -> | |
| X * Y. | |
| double(X) -> | |
| mult(X, 2). |
NewerOlder