รับจำนวนเต็มบวกnคำนวณค่าของฟังก์ชัน Mertens M ( n ) โดยที่
และμ ( k ) คือฟังก์ชั่นMöbiusโดยที่μ ( k ) = 1 ถ้าkมีจำนวนเฉพาะของปัจจัยสำคัญที่แตกต่างกัน -1 ถ้าkมีจำนวนเฉพาะของปัจจัยสำคัญที่แตกต่างกันและ 0 ถ้าปัจจัยสำคัญไม่ชัดเจน
- นี่คือcode-golfดังนั้นสร้างรหัสที่สั้นที่สุดสำหรับฟังก์ชันหรือโปรแกรมที่คำนวณฟังก์ชัน Mertens สำหรับจำนวนเต็มอินพุตn > 0
- นี่คือลำดับ OEIS A002321
กรณีทดสอบ
n M(n)
1 1
2 0
3 -1
4 -1
5 -2
6 -1
7 -2
8 -2
9 -2
10 -1
117 -5
5525 5
7044 -25
8888 4
10000 -23