‹ Back to the paper
A MOBIUS function returns the value or or for a natural number ( ) by the following conditions are…
A MOBIUS function $M(N)$ returns the value $-1$ or $0$ or $1$ for a natural number ($N$) by the following conditions are defined:
When,
$M(N) = 1$ if $N = 1$.
$M(N) = 0$ if any prime factor of $N$ is contained more than once.
$M(N) = (-1)^P$ if $N$ is the product of ‘P’ distinct prime factors.
Write a program to accept a positive natural number ($N$) and display the MOBIUS result with proper message.
Design your program which will enable the output in the format given below:
Sample 1
INPUT: 78
OUTPUT: 78 = 2 x 3 x 13
NUMBER OF DISTINCT PRIME FACTORS = 3
M(78) = -1
Sample 2
INPUT: 34
OUTPUT: 34 = 2 x 17
NUMBER OF DISTINCT PRIME FACTORS = 2
M(34) = 1
Sample 3
INPUT: 12
OUTPUT: 12 = 2 x 2 x 3
DUPLICATE PRIME FACTORS
M(12) = 0
Sample 4
INPUT: 1
OUTPUT: 1 = 1
NO PRIME FACTORS
M(1) = 1
Answer
No answer yet.
From ISC 2021 Specimen Computer Science Paper 2, question 3.