Guest User

Russian Peasant Multiplication2

a guest
Oct 25th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.11 KB | None | 0 0
  1.   1 #include <stdio.h>
  2.   2
  3.   3 int main(void)
  4.   4 {
  5.   5
  6.   6 int i,j,k=0;
  7.   7
  8.   8 for(i = 85; i>1; i /= 2){
  9.   9         j = 18;
  10.  10         j *= 2;
  11.  11         if(i%2 == 1){
  12.  12
  13.  13         k += j;
  14.  14         }
  15.  15 }
  16.  16
  17.  17 printf("%d\n",k);
  18.  18 return 0;
  19.  19 }
  20. ~                                                                                                                                              
  21. ~                                                                                                                                              
  22. ~                                                                                                                                              
  23. ~                                                                                                                                              
  24. ~                                                                                                                                              
  25. ~                                                                                                                                              
  26. ~                                                                                                                                              
  27. ~                                                                                                                                              
  28. ~                                                                                                                                              
  29. ~                                                                                                                                              
  30. ~                                                                                                                                              
  31. ~                                                                                                                                              
  32. ~                                                                                                                                              
  33. ~                                                                                                                                              
  34. ~                                                                                                                                              
  35. ~                                                                                                                                              
  36. ~                                                                                                                                              
  37. ~                                                                                                                                              
  38. ~                                                                                                                                              
  39. "ce.c" 19L, 157C written                                                                                                     17,1          All
Advertisement
Add Comment
Please, Sign In to add comment