ms_shnits

calculate A^N

Jun 10th, 2018
782
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. A = 2.5
  2. N = 7
  3. PRINT A^N
  4.  
  5. POW = 1
  6. i2 = A
  7. WHILE N > 0
  8.   IF (N MOD 2) = 1 THEN
  9.     POW = POW * i2
  10.     N = (N-1) / 2
  11.   ELSE
  12.     N = N / 2
  13.   END IF
  14.   i2 = i2*i2
  15. WEND
  16.  
  17. PRINT POW
RAW Paste Data