rate my factorial function
Is this b8?
Please report yourself
But just to sum up:
>Unecessary blank lines
>Unnecessary tabbing
>Inconsistent style
>%ld for usigned
>semicolon after 4
>Redundant if
>Redundant code
>Dumb code (using three variables for that shit)
>returning only if n<2, otherwise only printing
>It won't print for n<2
>Works for negative numbers
>Inline if
>Keeping argv for some reason
>No black line between the for and printf
it's trash
>>57224817
At least you didn't fall for the recursion meme
>>57224790
>after 4
after for
Tired as hell, it's after 4 here
Forgot
>That shitty (i-1) workaround
>Plebdows (probably on Mingw)
>That IDE
>>57224833
visual studio actually. why would i run something non native.
>>57224748
This shit is like the equivalent of tying your shoes... Poorly. It's good that you're proud of yourself for learning something new, but nobody is going to praise you for something so banal. If you're gonna learn how to program then do it for yourself, not just to fish for compliments, you're hella ways off from getting any. Frankly this just strikes me as sad.
>>57224883
someone is jealous of my raw talent.
>>57224933
kys
>>57224942
kek you're super?
return n < 2 ? n : n * factorial(n - 1);
DOUBLE PRECISION FUNCTION FACT(num)
DOUBLE PRECISION count, num, ans
count = 1D0
ans = num
DO WHILE (count .LT. num)
ans = ans * count
count = count + 1D0
ENDDO
FACT = ans
RETURN
END
>>57224933
Ohboy. I REALLY hope you're just trolling here.
Look... At least try writing a dijkstra or something, or at the VERY least do something with a tree.. Because if this thread isn't just a troll I legit feel sorry for you.
>>57224851
MinGW doesn't put telemetry calls into your compiled code. And it has better support for C99.
>>57224969
>fewer lines makes it run faster
>>57225079
Wish he'd at least do a tail recursion if he has to use it.
factorial = (head .) . (. scanl (*) 1 [1..]) . drop
>not implementing the gamma function
pleb
>>57224827
>>57225093
Recursion is a resource hogging gimmick. Unreadable and unprofessional
>>57225759
Depends on the problem. Some problems that are mathematically defined using recursion are much more readable when written as recursive functions than as an iterative function.
I asked my computer science department head and professor what single precision and double precision means and she didn't know. I'm a freshman but I'm 23. Should I be worried
> something{ };
> };
really?
>>57225759
try defining any graph algorithm, try do it without recursion. Which is clearer?
>>57225909
Doesn't it depend on the algorithm? Say BFS vs DFS
>>57224827
recursion meme? really? this is one of the few times recursion is a good implementation.
>>57225883
lmao do you go to Tyrone University or something?
Yes you should be worried because it sounds like both you and your teachers might be retarded
>>57225949
Nope. Recursion, though more clear, is usually worse than dynamic or inline solutions. Recursion wastes space. If your recursive solution has repeated steps (fibonacci for instance, since in f(n) + f(n+1), f(n) includes solutions needed for f(n+1)), then it'll run at least a factor worse than if you keep track of repeating solutions (which won't take quite much space as recursion)
>>57225957
I'm just a hobbyist. I go to a community college. I'm fairly confident I know more than the professor just from some books I read in my teens and lurking here since the 8800gtx days. I don't have any other options school wise right now so I'm really bummed, it look a lot of work to get off the streets and back into school.