Virat
  • 1

Write an algorithm prime(n) to check if n is prime. (Hint: A prime number p has exactly two distinct factors, 1 and p. Can you make use of divisors(n) to write out prime(n)?)

  • 1

Compute divisors(n) using our earlier algorithm to get the list of factors. If the list has exactly two elements, 1 and n, report that n is prime; otherwise, report it is not.

Cbse Class 9 Maths Ganita Manjari Part 2 Solutions
class 9 maths ganita manjari part 2 chapter 11 question answer

Share

1 Answer

    1. Compute the list of factors: let L = divisors(n).
    2. Check the number of elements in L:

    If the total count of elements in L equals 2 (which means its only factors are 1 and n), report that n is prime.

    Otherwise (if it has fewer than 2 elements, such as n = 1 or more than 2), report that n is not prime.

     

    For more NCERT Solutions of Class 9 Maths Ganita Manjari Part 2 Chapter 11 The World of Algorithms Question Answer (2026-27)

    https://www.tiwariacademy.com/ncert-solutions/class-9/maths/ganita-manjari-chapter-11/

    • 0
Leave an answer

Leave an answer

Browse