Count number of 1 s in the array after N moves | Function to count number of perfect squares ; Counting number of perfect squares between a and b ; Function to count number of 1 s in array after N moves ; Initialize array size ; Initialize all elements to 0
< ? php function perfectSquares ( $ a , $ b ) { return ( floor ( sqrt ( $ b ) ) - ceil ( sqrt ( $ a ) ) + 1 ) ; } function countOnes ( $ arr , $ n ) { return perfectSquares ( 1 , $ n ) ; } $ N = 10 ; $ arr [ 10 ] = array ( 0 ) ; echo countOnes ( $ arr , $ N ) ; ? >