Interview Question

Entry-level Software Developer Interview



Populate an array of numbers from 1 to N (inclusive). Given two numbers, p and q , if a number in the array is divisible by p print OUT, if a number is divisible by q print THINK. If number is divisible by both p and q, print OUTTHINK. Otherwise, print the number.

AnswerAdd Tags

Interview Answers

5 Answers


seems like a variation of fizzbuzz. Should not be difficult.

Anonymous on


"#Python Solution from array import * def problem_1(N,p,q): array_1 = array( 'i', range(1,N+1)) for n in array_1: if n % p == 0: print 'OUT' elif n % q == 0: print 'THINK' elif n % p == 0 and n % q==0: print 'OUTTHINK' else: print n problem_1(20,6,8)" Doent't work, think how an else-if sentence is used in compilation :)

Anonymous on


the second one is certainly fizzbuzz, you were overthinking.

Anonymous on


Or is it the actual interview? coding challenge = interview?

does IBM offer another round of interview if you pass this thing? on


// C++ Solution void divisibleArray(int array[], int size, int p, int q){ for (int i = 0; i < size; i++){ if (array[i] % p == 0){ cout << "OUT" << endl; }else if (array[i] % q == 0){ cout << "THINK" << endl; } else if (array[i] % p == 0 && array[i] % q == 0){ cout << "OUTTHINK" << endl; } else cout << array[i] << endl; } }

CJ on

Add Answers or Comments

To comment on this, Sign In or Sign Up.