Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(lab01).
- -compile(export_all).
- fibTerm(N) ->
- SQRT5 = math:sqrt(5),
- E1 = math:pow((1 + SQRT5), N),
- E2 = math:pow((1 - SQRT5), N),
- E3 = math:pow(2, N) * SQRT5,
- E4 = (E1 - E2)/E3,
- ANS = trunc(E4),
- io:format("After fibTerm ~w~n", [ANS]).
- isSame(N1, N2) ->
- if
- N1 =:= N2 -> true;
- true -> false
- end.
- mySign(N3) ->
- io:format("Entered Number is ~w, ", [N3]),
- if
- N3 > 0 -> positive;
- N3 < 0 -> negative;
- true -> zero
- end.
- smallest(N4, N5, N6) ->
- if
- (N4 < N5) and (N4 < N6) -> N4;
- (N5 < N4) and (N5 < N6) -> N5;
- true -> N6
- end.
- fruitType(N7) ->
- case N7 of
- 1 -> berry;
- 2 -> melon;
- 3 -> citrus;
- 4 -> tropical;
- 5 -> pomes;
- 6 -> drupes;
- _ -> no_match
- end.
- fruitType2(1) -> berry;
- fruitType2(2) -> melon;
- fruitType2(3) -> citrus;
- fruitType2(4) -> tropical;
- fruitType2(5) -> pomes;
- fruitType2(6) -> drupes;
- fruitType2(_) -> no_match.
- isPrime(2) -> true;
- isPrime(N8) when N8 < 2 -> false;
- isPrime(N8) when N8 > 2 -> isPrime(N8, 2).
- isPrime(N8, D) when (N8 rem D) == 0 -> false;
- isPrime(N8, D) when (D*D) > N8 -> true;
- isPrime(N8, D) when ((N8 rem 2) == 1) and ((D*D) =< N8) -> isPrime(N8, D+1).
- mySum(0) -> 0;
- mySum(1) -> 1;
- mySum(N9) when N9 > 1 -> N9 + mySum(N9 - 1).
- mySeries(N10, N11, N12) ->
- N10 * math:pow(N11, N12 - 1).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement