Reminder this is who gets to decide if you have a job

Reminder this is who gets to decide if you have a job.

Attached: interview.png (1000x417, 137K)

Other urls found in this thread:

news.ycombinator.com/item?id=8787565
en.wikipedia.org/wiki/Miller–Rabin_primality_test#Testing_against_small_sets_of_bases
en.wikipedia.org/wiki/AKS_primality_test
twitter.com/SFWRedditImages

>35 is a prime number

Attached: 1480540420690.jpg (562x527, 61K)

for prime numbers you have to check if its even
if not then from 3 to sqrt(NUM) check every other number whether NUM is divisible by it
and remember to only check for NUM that is a neighbour of a number that is divisible by 6, because that's where primes are
hope that helps

think you meant 25, brainlet

holy shit, is that, dare I say, the most efficient way of computing prime numbers?

he would be correct if he added 5 and 7 btw

but he didn't

121

news.ycombinator.com/item?id=8787565

You check if a number is even by checking if its %2 == 0, which is what you're doing anyway with the other integers. So just check if it's divisible by every integer between 2 and floor(sqrt(num)). It does the same, but it's easier to explain.

>if a candidate couldn't write the logic to determine if a number is prime or not... that's another red flag

Attached: .jpg (512x288, 19K)

what's bad about only wanting to hire people who know basic math?

Are you being coy, because it seems like you missed what's funny about it...

Attached: 1512773011681.jpg (250x250, 10K)

I get the image is laughing at the reddit poster but OP seems like he thinks asking this question is unjustified

Attached: 1501445452387.jpg (499x465, 20K)

am I missing the point or do you also think that expecting someone to know high school level math is unreasonable?

have you ever programmed anything, you would know why it's funny

What if that's not what OP is implying? What if it's actually that the guy in the picture just got it fucking wrong, yet he's the one in control of the interview questions and that's what's fucked up about it.

More than 100, so it's behind the scope. I agree it's useful to check for square root and cube root, but for numbers less than 100? Seems redundant.

>he thinks 25 is a prime number

>interviewer says not knowing how to write an is_prime() function is a "red flag"
>interviewer doesn't know how to write an is_prime() function and thinks its a trivial problem similar to solving fizzbuzz (its not).

the funny thing is that I've had this happen on an interview, there was an older guy and a tryhard junior doing the interview and the guy tied to correct me so I pointed out he was wrong too

guy turned red as a tomato, I couldn't hide my smirk at this time, you could tell he was about to die of embarrassment as I was showing him what he did wrong

It is trivial. Making it more efficient is a bit "tricky", but when time and space complexity are not important it is very easy.

Well i guess you didn't get the job?

I got called back but I did like 30 interviews that month and got a much better offer at a different company. It's not that big of a deal, the question was ridiculously hard and the older guy knew it, and as long as you can show that you are not "stuck" completely it's not really a problem which I obviously demonstrated by BTFO this little shithead that was with him.

Still one of the the most hilarious moments in my life, he was so fucking red I will never forget it, totally worth it just sitting there with a smirk on my face

>reddit
That's Hacker News

>falling for this obvious bait

Attached: 1548873302941.jpg (1125x1416, 122K)

number theorists BTFO by random recruiter

Attached: 1552348357652.jpg (2560x1920, 864K)

>It is trivial. Making it more efficient is a bit "tricky", but when time and space complexity are not important it is very easy.
And this assclown, who judges others' competence, failed to do it.

That recruiter obviously has a pole up his ass with a red flag dangling on it. How the fuck don't you know how to figure out if a number is prime or not.

so

I meant something like this

Attached: Untitled.png (1712x885, 51K)

[spoiler] BTFO [/spoiler]

Attached: IMG_2254.jpg (640x1090, 145K)

I see nothing wrong.

t. smtddr

who the fuck works for a company in 2019 this is why you people will never account to anything, work for yourselves you stupid cucks

I'm so appreciative of the pseudo-anonymous nature of imageboards, All the megabrainlet posts I've ever made (including one just earlier today) won't immortalized in a forum somewhere, and even if they're archive by a third party, can't be tied back to me.

>never account to anything

neither will you

>most tech people people are hyper-logical cold-hearted emotionless sociopaths

Attached: 1553030178341.png (512x548, 181K)

Show me a composite number that can be divided by 2 or 3 with a natural number as the result, then.

6

25

>tfw you're not landing a job in tech because you're not hyper-logical, cold-hearted, and emotionless
god damn it

Attached: 1419819348053.png (662x413, 76K)

I wrote composite instead of prime, try again.

You only have to check factors that are themselves prime, so if you're counting primes starting at 2, you can use the primes you've already determined in order to check the later ones. also, calculating sqrt is slow, so instead you can use the perfect squares. check every odd number between them and use the sqrt of the lower perfect square in each range as the greatest number you have to check (but only check prime numbers less than it).

0

Prime numbers have to be greater than 1

Both 6 and 25 are composite and not prime

Try isPrime(2).

>Python programmers
lmao

>ridiculously hard
nigger I did this shit in highschool if someone cant do it after a BS in CS then they should unironically kill themselves for being a waste of carbon

>Python PROGRAMMERS

Attached: giphy[1].gif (480x287, 667K)

that's not the actual reasoning why 0 is not prime, retard

Attached: IMG_2256.jpg (1300x1093, 81K)

nice catch my man

Attached: Untitled.png (640x835, 20K)

It's been beaten in my head the algorithm for finding prime numbers thanks to interview after interview. Slipping such an addition to fizzbuzz is nothing to me.

so is this the ultimate final best of the best way to check if the number is prime?

Attached: Untitled.png (681x427, 10K)

>be interviewer
>bring advent of code page up during interview

Attached: 1445467916372.png (425x450, 316K)

My greatest weakness is vocabulary/algorithm memorization. It's my own fault for always defaulting to taking the 1 second to Google it but still. Even for things as common as primes I might forget what a prime number is. I know it's a mathematical term that can be expressed as an algorithm, but making sure I remember the lexical name combined with the mathematical formula is where it falls apart. I'd rather not make assumptions and always confirm something is what I think it is by checking the reference first.

This is also due to heavy abstractions that come as a RESULT of practice. I don't remember how to floor an int because if I want to do that I just call floor() on it obviously. Implementing those functions are school exercises which means 10 years ago for me.

learning programming by interview grinding has to be pretty legit.

No. The fast algorithms use probabilistic methods first, like checking some values of Fermat's little theorem.

I actually quite sick of it actually. 200 apps out, I just want to work damnit.

>I don't remember how to floor an int
I think you are just retarded

What's the point in remembering not only how to do it but how to implement it efficiently in several languages? It's totally irrelevant and counter to the whole point of abstraction in the first place imo. I don't want to think "I need to floor this, how do I do that, then what do I do" I want to think "I need to floor() this then something else"

You don't seem to even understand what floor() is supposed to do.

He's an ultrafinitist who believes 24 is the biggest number.

>trial division
>not a primality test like miller rabin
>not at the very minimum pre-sieving up to sqrt(2**64-1), which is 4294967296, and the range has 203280221 primes, requiring 1.51GiB of storage to store at 8-bytes a number, allowing you to test trial division by primes only instead of all odd numbers
>probabilistic
They can be proven deterministic for below some numbers, actually:
>en.wikipedia.org/wiki/Miller–Rabin_primality_test#Testing_against_small_sets_of_bases
>if n < 18,446,744,073,709,551,616 = 2^64, it is enough to test a = 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, and 37
So unless you're into bignum territory, primality testing is deterministic.

All I did was mistakenly say "an int" instead of "a number". Because internally, the "int" keyword and "number whos type is irrelevant" are synonymous. But you're missing the broader point by focusing on that detail.

BASED

>storing 8-byte prime numbers during a pre-sieve
>not setting bit indicators in a bit field
We'll get back to you about the job user.

Reading comprehension. He has experienced a situation where the interviewer fucked up, he never wrote what specific question it was.

Is the joke that almost all prime numbers are uneven and following his orders of printing from 102 in decrements of 2 you'd never hit a prime number?

user isn't missing anything. A number is a number, an int is an int. You may have misspoken when you said "floor an int" but that doesn't make it any more of a dumb thing to say.

I admitted it was a mistake and expressed it's not the focal point. What more do you want? What sense is there in being a pedant?

The only way to find prime numbers to use a prime sieve. I wasn't even taught this in 4th grade like everybody else, so when I was asked to calculate primes up to 100 and sort them, I couldn't. I wrote a shitty function that looked like

const isPrime = (num) => {
for (let i = 0; i < num; i++) {
if (num % i === 0) {
return false;
}
}
return true;
}


I hate myself for this... but more importantly, I hate that this random trivia question ruined my chances of getting in. Was I supposed to invent a prime sieve on the spot? if only I knew about it, if only it wasn't buried by meaningful topics like hash tables, trees, and other important data structures.

Excuse my JS. I've been using exclusively for the last 1.5 years and I've forgot how to Java.

There's nothing wrong with your solution. A prime sieve would use growing amounts of space to store all the primes. Your solution uses constant space at the cost of time. Note that the state of the art for prime testing is not something anyone can be reasonably expected to produce during an interview.

>Note that the state of the art for prime testing is not something anyone can be reasonably expected to produce during an interview.

This is why you don't have a job

>A prime sieve would use growing amounts of space to store all the primes.
Good lord, being this nocode.

You're gonna come up with this on the spot?
en.wikipedia.org/wiki/AKS_primality_test

Attached: IMG_2239.png (1440x1557, 738K)

>Was I supposed to invent a prime sieve on the spot?
I gave up on teaching myself programming because I was learning from a book that was full of challenges like that. I really struggled to do any of them, and thought, "If I'm this bad at the basic stuff, maybe I should just quit." But I always suspected I was missing something, because there's no way anyone could read that book and think it was easy.

If you can't write in 5 minutes or less a function which checks if a single integer is prime or not, you don't deserve to call yourself even a hobbyist coder.

Hint: you don't need a fucking sieve to check if a certain number is prime.

We only want the BEST for the job; if you aren't up to the likes of Dinesh and Shaquana, then why are you applying?

The poster I responded to expected a state of the art solution
A basic prime testing function is a different matter entirely and I never claimed it's unreasonable to ask for one in an interview

35 also works, turbo-brainlet. its prime factorization is 5x7

>The poster I responded to expected a state of the art solution
No, he didn't, autismo. He was merely disagreeing with your naive assumption that one was required.

>He was merely disagreeing with your naive assumption that one was required.
I didn't assume that retard. I was replying to
who gave a perfectly good solution but felt it wasn't good enough and I was informing him that he doesn't need a state of the art solution

>57
>not a prime

Same shit

#include
#include

static int *primes;
static int capacity;
static int size;

static int init(void)
{
primes = malloc(10 * sizeof(sizeof(primes[0])));
if (primes == NULL) {
return -1;
}
capacity = 10;
size = 0;
return 0;
}

static void finish(void)
{
free(primes);
}

static int add(int p)
{
printf("%d\n", p);
if (size == capacity) {
int *np;
capacity *= 2;
np = realloc(primes, capacity * sizeof(primes[0]));
if (np == NULL) {
return -1;
}
primes = np;
}
primes[size++] = p;
return 0;
}

static int isnew(int i)
{
int j;
for (j = 0; j < size; j++) {
if (i % primes[j] == 0) {
return 0;
}
}
return 1;
}

int main(int argc, char *argv[])
{
int i;
int l;
switch (argc) {
case 1:
l = 1000000;
break;
case 2:
if (sscanf(argv[1], "%d", &l) != 1) {
fprintf(stderr, "usage: %s [LIMIT]\n", argv[0]);
return EXIT_FAILURE;
}
break;
default:
fprintf(stderr, "usage: %s [LIMIT]\n", argv[0]);
return EXIT_FAILURE;
}
if (init() != 0) {
fprintf(stderr, "out of mem\n");
return EXIT_FAILURE;
}
for (i = 2; i

What the absolute fuck? what company is this? how do you get this retarded?
x mod 2 > 0 and x mod 3 > 0 does not mean x is a prime.
The definition of a prime number is a number that is only divisible by itself and 1.

constexpr int max = 103;
bool sieve_composite[max] = {0};
for(int i = 2; i < max; ++i){
if(!sieve_composite[i])
for(int j = i*i; j < max; j+=i)
sieve_composite[j]=1;
}
for(int i = max-1; i > 3; --i){
if(sieve_composite[i])
std::cout

def isPrime(num):
if num < 2:
return False
else:
for i in range(num):
if num % i == 0:
return False
return True

How did I do?

def is_prime(num):
while(1){
require(is-odd.js)
#include
void *prime = malloc(sizeof *stdlib.h);
if not !True: print(return;);
}

sieve of eratosthenes is pretty cool and has a great historical importance. It's not the most efficient though.

>pointless else statement causing unnecessary indentation
>checking even numbers when 2 suffices
>not just checking if odd
>checking the entire range instead of just sqrt(n)
Failed middle school math tier.

He was trolling.

If you don't care about complexity then finding prime numbers is easy.

Genius, when can you start?

Noone says it's necessarily easy. It also depends what book you read, some are more targeted towards universities or mathematicians learning to code.

Doubt you finished high school with that level of reading.