Search code examples
mathgraphgraph-theorydiscrete-mathematics

How many components are there in graph?


A simple graph has vertices which are labeled between 2 and 120. There is an edge between two vertices of graph if b = a*k where a, b are vertices and k is any natural number. How many component does this graph have?


Solution

  • This question is not about programming indeed. I will still answer it because it is fairly easy:

    All vertices with a prime number > 60 will be alone, so: 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113

    Everything else will be connected to one component: The 2 will connect together all even numbers. And all prime numbers <= 60 will connect to another even number by taking k = 2