我需要一种算法,允许我根据页面的视图和注释计数<priority>为我的网站的站点地图确定一个合适的字段.
对于那些不熟悉站点地图的人,优先级字段用于表示页面相对于同一网站上其他页面的重要性.它必须是介于0和1之间的十进制数.
该算法将接受两个参数,viewCount并且commentCount,将返回的优先级.例如:
GetPriority(100000, 100000); // Damn, a lot of views/comments! The returned value will be very close to 1, for example 0.995
GetPriority(3, 2); // Ok not many users are interested in this page, so for example it will return 0.082
Run Code Online (Sandbox Code Playgroud)