>>498
>>502と同じ疑問を持った。
Rubyで。
http://ideone.com/BKToA1

k=8 answer = [1, 6]
k=123 answer = [25, 121]
k=13 answer = [4]