We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
it's basically a problem to check if two different arithmetic progressions have a same term at some n.
leta1=x1andd1=v1anda2=x2andd2=v2now=>a1+(n-1)d1=a2+(n-1)d2=>a1+a2=(n-1)(d2-d1)=>(a1+a2)/(d2-d1)=n-1=>n=1+(a1+a2)/(d2-d1)// ensure (d2 - d1) = 1 if it is zero, to avoid errorifn>0thenYESotherwiseNO
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →
it's basically a problem to check if two different arithmetic progressions have a same term at some n.