small program to write in CUDA

i have to write program, but i dont have a clue how 2 do it, this is small riddle for CUDA developers :

thx 4 answers :)

i need to write a program which search divisors of given number


on input program expecting on natural number ‘y’, for this number ‘y’ need to check n=floor(srt(y)) divisors

program need to use a few arrays:
array C,D ,E - arrays type of int, size of n, arrays dont need to be inniciated

algorythm must work on one dimension grid


  1. run n threads

  2. every thread on x number need check, that number ‘y’ can be devided by x+1(we dont want divide by 0).
    if number y can be devided by x+1, thread should save to array C, under position x value 1, else save 0

  3. use EXCLUSIVE SCAN using sum operator on array C, results save to array D.

  4. run again n threads

  5. every thread with number x in grid, should check that in array C, under position x in saved 1 or 0.
    if 0, thread dont need to do nothing, but if is 1, thread should read from array D from x position value ‘i’, next
    should save to array E, under position ‘i’ , number x+1

  6. array E keep list od founded divisors of figure(number) ‘y’. amount of founded divisors is equal sum of last
    element of array C and last element of array D.

i think, you should take some time to read the programming guide and look some examples of the SDK. They are very helpful…

ofcourse , and i know that i dont need any sarcasms,if u dont want help me u should save this comment 4 u, i expect solutions not advices :)

if someone have little of time i believe he can solve this riddle 4 excercise and that will be helpfull 4 me :D