Sandeep Banerjee

Sandeep Banerjee

  • NA
  • 249
  • 263.7k

unable to solve a prob

Nov 12 2017 5:33 AM
hi, Its a silly question but there is some issue in my calculation, as when i do
 
8535902775%10 it show -7 on my php compiler 
however i expect as it shuold be 5 i know modulo thing as currently i am not able to find my istake my program is:
 
  1. <?php   
  2. $isbn=8535902775;   
  3. //{Write your code here  
  4. $array='0';  
  5. for($i = 1; $i<=10;$i++){  
  6.     $array += $isbn % 10;  
  7.     $isbn = $isbn/10;  
  8.     $array = $array * $i;  
  9. }  
  10. if($array/11 == 0){  
  11.     echo "Valid";  
  12. }else{  
  13.     echo "Not Valid";  
  14. }  
  15. ?>  
 

Answers (2)