Cs grad thread. Fresh content only

cs grad thread. Fresh content only

Attached: tail-recursion.png (694x453, 117K)

Aside from that code not working. There's no problem with this

I don't understand the CS grad hate.

Despite how good of a programmer you are, if you can't commit to four years of easy classes it looks bad. I get that cost is an issue, but then some of you spend 2k on gaming PCs.

>if you can't commit to four years of easy classes it looks bad.
Absolutely nobody gives a shit if you can sit through 4 years of classes.

>he can't see the answer
I can assure you this code is bad.

I'm about to be a cs grad myself. It's just banter. None of us knew everything from the get-go. You shouldn't take things so seriously, let alone anything on this site at all.

It‘s just a way for neets to cope.

Yea tell that to the job offer that I just got last week who wouldn't have even viewed my resume if I was uneducated

>four years of easy classes
Not even that, 3 years.

Yeah. Tell that to the company that hired me at 180k with no degree.

Nice larp. This doesn't happen anymore unless you're in your 30s-40s and have been working for 10+ years.

Say that to an airline pilot or heart surgeon. You wouldn't want your doctor to be "self taught" so why the people who build the systems you use everyday for banking, comms, etc?

Still gonna be hard as hell for you to find a job. Been a neet for many many years.

It's not tail-calling. It performs very poorly even with not-too-large inputs.

>spoonfeeding

You have to be over 18 to post on this site.

Spending $2k on a gayming PC while you're employed is not a big deal, considering it will last for a few years.
A degree costs tens of thousands, and you won't be able to work full time and make decent money.

>factorial(-10);
into the trash

Keep larping boomer

Yea I agree. I am just saying that almost everyone I've gone to University with who's complained about finances tends to also spend ridiculous amounts on stupid things.

I got lucky enough to have a paid mentorship while at school and am only leaving with 15k in debt. I have friends in the 40-55k debt range though

0% of the time, it works every time

>doctor makes a mistake
>person dies
>programmer makes a mistake
>program segfaults

don't try and be disingenuous with me, faggot

more like
>programmer makes a mistake
planes start crashing into the ground

If I had gone to a university after graduating from public school, I don't know how I would have managed to keep my debt below $40k.
A lot of my friends are in pretty deep debt because part-time college jobs just don't pay enough to make up for tuition, fees, books, and housing expenses.

Housing is what fucks people.

Usually people tend to take out loans for housing which is what I avoided doing.

>Go to CC first for two years
>Work as much as you can without fucking up academics
>stay in state

Could be making 250k+ if you had that degree, but sure think you're ahead if it makes you feel better

>programmer makes a mistake
>bank transactions get lost
>they make sure the programmer never finds a job in that country

Actually most people do care

I could not live with my parents any longer, so I would have needed to find housing, and blow thousands of a year on that.
Instead I cheated and joined the military. Now I do wireshark/scripting things and teach myself C when I have spare time at work.

That definitely can be tail call optimized.

This is legitimately solid advice

int factorial(int n){
if(n==0) return 1;

return n * factorial(n-1);
}


factorial(int):
mov eax, 1
test edi, edi
je .L1
.L2:
imul eax, edi
sub edi, 1
jne .L2
.L1:
ret

The input 0 should actually return one as 0! = 1 not saying using recursion for a function that can be calculated iteratively is a good idea.

It compiles to a loop anyway.

A sufficiently good optimizing compiler can do it, yes, but that's not guaranteed.

>It's not tail-calling.

The code is not in tail-calling form.

There's no such thing as a tail-calling form for code.

I can do all the comp sci classes but the maths aren't easy for me so I might drop out. Can't believe poor people go into debt for this, it's not worth huge amounts of debt at all.

>CS grad
you were too much ofa brainlet for math, and too much of a cuck for EE.
t.EE/math double major working as a developer

If the function ends in a function call, that's tail-calling. n * factorial(n-1) is not tail-calling. The standard does not guarantee that will be optimized.

Third world countries are the best to get your first job and pass the big filter (the first job).

There's no standard. There's no tail call optimization promises in C nor in C++ standard.

int factorial(int n, unsigned long long acc)
{
if (n < 1) return acc;
return (n - 1, acc * n)
}

tail call optimization!

are you mentally retarded
google "how to tail call optimize a function" and you will find that their is a form to it.
An additional variable can be used to keep the running total, allowing the previous calls to be dismissed

Attached: file.jpg (433x427, 86K)

Attached: F276A4CB-5803-45D3-8BE1-9301AD51B278.jpg (2435x454, 328K)

It already is tailed call optimized by the earliest variable GCC compiler for that compiler explorer site. Don't believe whatever drivel lisp programmers write on the first site you find via google search.

You're right, I remembered wrong. Nonetheless, it's a safe bet that if you want tail-call elimination, write your code in tail-calling form -- not all compilers might be smart enough, and in more complex functions the optimization may be harder to detect.

5 years if you didn't go to high-school, neet.

You'll take an entire year of spanish, algebra, etc.. And then start your actual degree, which is two years of calculus, physics, etc.

>easy classes
the fuck university you all go to

>cheating is joining the military
user.. I...

Attached: Wb29jaO.jpg (1125x825, 171K)

If you live in a third world shithole with a shitty education system.

I live in USA, retard. And yes it's a world-class shitty education system and I didn't go to highschool.

Now I've been fucking taking an entire year of pre-calc and spanish and still have 4 more years to go for an ABET accredited CS degree.

Literally just requires a high school diploma and to not be physically fucked up.
Once I'm finished I'll get 3 years of college 100% paid for, I've earned an associates degree, multiple certs (all paid for by the military), and on top of that get a comfy paycheck.
I work less than 40 hours a week on average and my pre-tax salary would be above $70k.

Feels like cheating because I do a similar job to my friend who did 4 years of college (which is not cheap), and now gets paid half of what I do.

It's so so

Worst part is you can't cuddle with the misses

How're you getting 70k in the military? I thought officers started at 35k or some bollocks. I thought they paid absolutely shit, like 20k a year. Is this USA?

Input/output should be unsigned, you absolute brainlet. Enjoy your infinite recursion if you input something negative.

Why not just

int factorial (int n) { if (n > 0) return n * factorial(n-1); }

kek, except it's missing the actual tail call.

Try factorial(0).

>tfw a top uni kicked me out of CS so I'm doing math

Very true. Part of it is that you're giving up the freedom to choose where you live, who you work for, and possibly getting deployed to some shit zone for anywhere from 4 to 12 months.

> I thought officers started at 35k or some bollocks.
You're probably just thinking of "base pay" which is only a part of your paycheck.
I'm in the US Air Force. I get food allowance, housing allowance, utility allowance, etc. I'll post my pay stub which breaks it down in a minute.

Compiler error. factorial's definition ends before a return statement is guaranteed. The problem with the OP is it returns zero so the function will always return zero when n times zero is calculated.

It's okay m8, I can't join anyway since I'd have to lie to get a top secret clearance which means no upward progression.

did 2 many drugs when i was 18

>22,052
Shaniqua and her 5 kids thank you, user.

>yeah mate just go and plug in ur usb stick and deploy autopilot2.0 and don't wake me up again

Are you a retard or just pretending?

g++ no -O flags allowed

Attached: Screen Shot 2019-04-25 at 2.06.49 PM.png (1720x872, 156K)

It's almost like we shouldn't trust programmers with our lives. This isn't a matter of bad programmers, it's a matter of retarded corporate exec boomers thinking they can automate everything with computer magic.

My guy this is real.
737's started to fall from the sky because a program tried to compensate for data from a faulty sensor and had no way to drop to manual control.
Auto pilot fucking forced the plane to nosedive with no way for the pilot to interfere.

>I'd have to lie to get a top secret clearance
Not saying that you should lie, but if you tell them you didn't do any drugs, you didn't do any drugs.

> no -O flags allowed
lol

0! = 0
what the fuck

This is what a USAF paycheck looks like if you're stationed overseas.

Attached: annotated_paycheck.png (1216x566, 88K)

I know. But I can live on 160k.

Amateurs!
int factorial(int n) {
if (n == 0) {
return 1;
}
else if (n == 1) {
return 1;
}
else {
int f = 0;
for (int i = 1; i

Because the majority of CS graduates are literal retards who think that reading some books equates to in real life skills and knowledge, but for some odd reason struggle with easy things like fizzbuzz.

press F to pay respect

>fib

Loll if you think cs students read either, instead of cheating on the autistic Asian.
Hell, all the Indians in my program (like 80% of the student body) are all losers and hang out at the school ALL DAY. they still do terrible in classes.

The possibility of getting shot at might also deter some.

you caught me I was thinking of the other freshman recursion exercise they give you when I wrote this

Aw shucks dem college kids n their book learnin' dey don' know nuffin

lmao I pay €264 a year for CS in my college

The only thing a college degree does is prevent them from immediately throwing your application away, instead you get thrown away in the next round because of other bullshit requirements like experience that you need for a job but never had a job to get that experience putting you stuck in a cycle.

>t. code bootcamp cuck

America is a third-world shithole.

>his function returns ints

you fucking pleb

#include

double fact_nopleb(unsigned int Numb)
{
if(Numb < 0) throw "Fuck you";

double DELTA_T = 0.001,
L_BORDER = 0,
R_BORDER = 2000*Numb,
Gamma = 0;
int i = 1;

while (L_BORDER

Attached: 61c2ef993e435456286adc5cce276900444e5e97.jpg (441x373, 17K)

>t. europoor nigger

Actually I personally never did that. I don't know shit about programming. Just a NEET anxious loser.

meant double fact_nopleb(double Numb) ,sorry

Is being NEET redpilled?

Recursion is for fucking babies. Anyone can write a recursive solution. Literally the easiest shit.

Making an iterative solution with dynamic programming caching the results is what men do.

There is nothing to check if n== a negative number. Also what is the reason for this code to exist. If you wanted n to be 0 then why not change it to zero directly? Only in small situations you want it to count down but just why?

Dynamic programming is a total meme no true chad will use that garbage.

Retarded neet. If you cant do dynamic programming you cant even get past interviews

>Also what is the reason for this code to exist. If you wanted n to be 0 then why not change it to zero directly

this is supposed to compute n! = n*(n-1)*(n-2)...
They ask you this in high school or so just so you get that
A) recursion exists and
B) You probably shouldn't use it unless you don't have a choice.

OP just fucked up and didn't know 0! = 1

I don't know. Honestly with my issues I feel hell no matter what a lot of the time. Most source of stress being money related things. I don't get any neetbux or anything and just so low to ask for even 50 dollars to go to the grocery store.

Programming is giving me a bald spot, stressful when your dependencies fuck up. Stupid npm and pip

God I wish I was American I would take the military free ride immediately. British military sucks ass, absolutely shit pay, underfunded and no benefits whatsoever like tuition or extra for housing or anything.
Fuck I hate this shithole island.

What's the matter, couldn't resolve is-even?
Serves you right millennial fuck

npm install factorial-recursive