LeoLDB

INFO - ULTIMA CIFRA a^b

Jan 19th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. int ultimacifra(unsigned a,unsigned b)
  2. {
  3. int c=a%10;
  4. if(c==0||c==1||c==5||c==6)
  5. return c;
  6. else
  7. if(c==2)
  8. {if(b%4==0)
  9. return 6;
  10. else
  11. if(b%4==1)
  12. return 2;
  13. else
  14. if(b%4==2)
  15. return 4;
  16. else
  17. return 8;}
  18. else
  19. if(c==3)
  20. {
  21. if(b%4==0)
  22. return 1;
  23. else
  24. if(b%4==1)
  25. return 3;
  26. else
  27. if(b%4==2)
  28. return 9;
  29. else
  30. return 7;
  31. }
  32. else
  33. if(c==4)
  34. {
  35. if(b%2==0)
  36. return 6;
  37. else
  38. return 4;
  39. }
  40. else
  41. if(c==7)
  42. {
  43. if(b%4==0)
  44. return 1;
  45. else
  46. if(b%4==1)
  47. return 7;
  48. else
  49. if(b%4==2)
  50. return 9;
  51. else
  52. return 3;
  53. }
  54. else
  55. if(c==8)
  56. {if(b%4==0)
  57. return 6;
  58. else
  59. if(b%4==1)
  60. return 8;
  61. else
  62. if(b%4==2)
  63. return 4;
  64. else
  65. return 2;
  66. }
  67. else
  68. if(c==9)
  69. {
  70. if(b%2==0)
  71. return 1;
  72. else
  73. return 0;
  74. }
  75. }
Add Comment
Please, Sign In to add comment