Print squares of first n natural numbers without using * , / and | Javascript program to print squares of first ' n ' natural numbers wothout using * , / and - ; Initialize ' square ' and first odd number ; Calculate and print squares ; Print square ; Update ' square ' and ' odd ' ; Driver program to test above function
function printSquares ( n ) { let square = 0 , odd = 1 ; for ( let x = 0 ; x < n ; x ++ ) { document . write ( square + " " ) ; square = square + odd ; odd = odd + 2 ; } } let n = 5 ; printSquares ( n ) ;