Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: ISC COMPUTER SCIENCE PRACTICAL SPECIMEN PAPER 2021: QUESTION 3 MOBIUS FUNCTION

Thursday, September 30, 2021

ISC COMPUTER SCIENCE PRACTICAL SPECIMEN PAPER 2021: QUESTION 3 MOBIUS FUNCTION

Question 3
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

ISC COMPUTER SCIENCE PRACTICAL SPECIMEN PAPER 2021

ENTER A POSITIVE INTEGER:

No comments:

Post a Comment