Sunday , December 11 2016
Home / JAVA / ISC Class 12 / Java Program to find Mobius Function of number

Java Program to find Mobius Function of number

Mobius Function Java Program:  The MOBIUS function µ(n) for a natural number N is defined as follows:

µ(n) = 1 if n is a square free positive integer with an even number of prime factors.
µ(n) = 0 if n has a squared prime factor.
µ(n) = -1 if n is a square free positive integer with an odd number of prime factors.

Example:

µ(26)=1                ( for 26 = 2 * 13     µ(26) = ( -1)^2= 1 )

µ(19)=-1               ( for 19 = 19     µ(19) = ( -1)^1= -1 )

µ(62)=1                ( for 62 = 2 * 31     µ(61) = ( -1)^2= 1 )

µ(28)=0                ( for 28 = 2 * 2 * 7     µ(28) = 0 for 2 appears two times )

 

 Output:

Enter a number : 78
Value of Mobius Function : -1

Enter a number : 12
Value of Mobius Function : 0

Enter a number : 34
Value of Mobius Function : 1

Enter a number : 17
Value of Mobius Function : -1

 

Also See:   Java program to check for a happy number

Check Also

Program for Fascinating Number in JAVA

Fascinating Number :- The number of 3 digit or more, when we multiplied that number ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.