## 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.

6

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

Anonymous on

1

"#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

0

the second one is certainly fizzbuzz, you were overthinking.

Anonymous on

0

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

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

0

// 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