JavaScript code for PE problem 247 added.