------------- Assignment 1 ------------- -module(erlanghw). -export([isPrime/1]). %Assumes > 0 isPrime(X) -> case X of 1 -> 0; 2 -> 0; _ -> isPrime(X-1,0) end . isPrime(X,accumulatedTotal) -> case X of 2 -> (accumulatedTotal+2); _ -> case (X rem 2) of 0 -> isPrime(X-1,accumulatedTotal); _ -> isPrime(X-1,accumulatedTotal+X) end end . ------------- Assignment 2 ------------- -module(erlanghw2). -export([run/0,getSumOfDigitsOf/1,addErUp/3]). run() -> d = math:pow(2,1000), getSumOfDigitsOf(d). getSumOfDigitsOf(X) -> digAsStr = lists:flatten(io_lib:format("~p" , [X])) . addErUp(s,i,acc) -> true, lists:sublist(s,i)