yeah i know that about lcm of all numbers , i just dont get your solution. of using number of primes[n] +n -3
You need to create array of number_of_all_primes_before 1000000 just once to solve TLE issue and the answer will be number_of_all_primes_before[n] + n - 3 seconds.
@fyter_112
[1, 2, 3, 4, 5, 6, 7] =>
[1, 2, 3, 4, 5, 42, 42] =>
[1, 2, 3, 4, 210, 210, 42] =>
[1, 2, 3, 420, 420, 210, 42] =>
[1, 2, 420, 420, 420, 210, 42] =>
[1, 420, 420, 420, 420, 210, 42] =>
[420, 420, 420, 420, 420, 210, 42] =>
[420, 420, 420, 420, 420, 210, 420] =>
[420, 420, 420, 420, 420, 420, 420]
You are getting 4 as output for 4 while it should had been 3
Oh okay bro thanks
i just tested i am getting 3
before changing the code or after changing it?
i copy pasted my submission and tested with N=4 i got 3 as output
let me check ur code once
Thank you very much for the tip
np bruh
i ran your code on my local machine, it is giving me 4 as output for 4
Read but not able to figure out where i am wrong!!!
Yes you are right.
Minimum steps required is k+n-4 where k = number of primes <= n.
This problem is similar to the GOSSIP problem: https://www.math.uni-bielefeld.de/~sillke/PUZZLES/gossips.pdf
@admin look at this
bruh its different question in the article, f(3)=2, f(4)=3 in our case and it is not f(3)=3,f(4)=4
so they aren’t the same
Can anyone please explain how is the answer prime[n]+n-3?
In this discussion we are telling that it is not working bruh, but if u still want to know the answer here it is Helping Hands - #33 by sixofdiamonds