Find the integers that doesnot ends with T1 or T2 when squared and added X | Function to print the elements Not ending with T1 or T2 ; Flag to check if none of the elements Do not end with t1 or t2 ; Traverse through all the elements ; Temporary variable to store the value ; If the last digit is neither t1 nor t2 then ; Print the number ; Set the flag as False ; If none of the elements meets the specification ; Test case 1 ; Call the function ; Test case 2 ; Call the function
function findIntegers ( n , a , x , t1 , t2 ) { let flag = true ; for ( let i = 0 ; i < n ; i ++ ) { let temp = Math . pow ( a [ i ] , 2 ) + x ; if ( temp % 10 != t1 && temp % 10 != t2 ) { document . write ( temp + " " ) ; flag = false ; } } if ( flag ) document . write ( " " ) ; } let N = 4 , X = 10 , T1 = 5 , T2 = 6 ; let a = [ 3 , 1 , 4 , 7 ] ; findIntegers ( N , a , X , T1 , T2 ) ; document . write ( " " ) ; N = 4 , X = 2 , T1 = 5 , T2 = 6 ; let b = [ 2 , 18 , 22 , 8 ] ; findIntegers ( N , b , X , T1 , T2 ) ;