Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. int nz(int n){
  2. int ot = 0;
  3.  
  4. //ezt azert, hogy csak minden 5-iket vizsgalja
  5. if(n%5!=0)
  6. n -= n%5;
  7.  
  8. //divide et impera:
  9. if(n%78125/*5^7*/==0){
  10. if(n%9765625/*5^10*/==0){
  11. if(n%48828125/*5^11*/==0){
  12. if(n%244140125/*5^12 - ez a max ami meg kisebb mint 1.000.000.000*/==0){
  13. ot = 12;
  14. }else{
  15. ot = 11;
  16. }
  17. }else{
  18. ot = 10;
  19. }
  20. }else{
  21. if(n%390625/*5^8*/==0){
  22. if(n%1953125/*5^9*/==0){
  23. ot = 9;
  24. }else{
  25. ot = 8;
  26. }
  27. }else{
  28. ot = 7;
  29. }
  30. }
  31.  
  32. }else{
  33. if(n%625/*5^4*/==0){
  34. if(n%3125/*5^5*/==0){
  35. if(n%15625/*5^6*/==0){
  36. ot = 6;
  37. }else{
  38. ot = 5;
  39. }
  40. }else{
  41. ot = 4;
  42. }
  43. }else{
  44. if(n%25/*5^2*/==0){
  45. if(n%125/*5^3*/==0){
  46. ot = 3;
  47. }else{
  48. ot = 2;
  49. }
  50. }else{
  51. ot = 1;
  52. }
  53. }
  54. }
  55.  
  56. if(n>0){
  57. return ot + nz(n-5);
  58. }else{
  59. return 0;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement