(50g) Möbius function (MOB)
03-16-2018, 02:34 PM (This post was last modified: 03-16-2018 02:49 PM by Joe Horn.)
Post: #1 Joe Horn Senior Member Posts: 1,687 Joined: Dec 2013
(50g) Möbius function (MOB)
The Möbius function, used in number theory, usually written as μ(n) but called MOB(n) here, is defined thus:
• MOB(n) = 0 if n has a squared prime factor.
• MOB(n) = 1 if n is a square-free positive integer with an even number of prime factors.
• MOB(n) = −1 if n is a square-free positive integer with an odd number of prime factors.
Examples:
• MOB(32) = 0 because it has a squared prime factor (it can be divided by 2^2).
• MOB(33) = 1 because it is square-free and has an even number of prime factors (3 and 11).
• MOB(30) = -1 because it is square-free and has an odd number of prime factors (2, 3, and 5).
Here is an HP 50g program that returns MOB(n) for any positive integer n.

Code:
\<<    IF DUP 1 -   THEN FACTORS AXL DUP SIZE 2. / 2. + RDM TRAN AXL EVAL 1. +     IF \PILIST 1. SAME     THEN SIZE 2. MOD -2. * 1. + R\->I     ELSE DROP 0     END   END \>>

BYTES: 132.5 #2EE7h

<0|ɸ|0>
-Joe-
 « Next Oldest | Next Newest »

 Messages In This Thread (50g) Möbius function (MOB) - Joe Horn - 03-16-2018 02:34 PM RE: (50g) Möbius function (MOB) - Luigi Vampa - 03-16-2018, 03:26 PM RE: (50g) Möbius function (MOB) - DavidM - 03-16-2018, 07:25 PM RE: (50g) Möbius function (MOB) - Joe Horn - 03-17-2018, 02:06 PM RE: (50g) Möbius function (MOB) - Gerald H - 03-17-2018, 05:58 AM RE: (50g) Möbius function (MOB) - John Keith - 03-17-2018, 09:38 PM RE: (50g) Möbius function (MOB) - Joe Horn - 03-18-2018, 06:08 AM RE: (50g) Möbius function (MOB) - pier4r - 03-17-2018, 11:12 PM

User(s) browsing this thread: 1 Guest(s)