Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int nz(int n){
- int ot = 0;
- //ezt azert, hogy csak minden 5-iket vizsgalja
- if(n%5!=0)
- n -= n%5;
- //divide et impera:
- if(n%78125/*5^7*/==0){
- if(n%9765625/*5^10*/==0){
- if(n%48828125/*5^11*/==0){
- if(n%244140125/*5^12 - ez a max ami meg kisebb mint 1.000.000.000*/==0){
- ot = 12;
- }else{
- ot = 11;
- }
- }else{
- ot = 10;
- }
- }else{
- if(n%390625/*5^8*/==0){
- if(n%1953125/*5^9*/==0){
- ot = 9;
- }else{
- ot = 8;
- }
- }else{
- ot = 7;
- }
- }
- }else{
- if(n%625/*5^4*/==0){
- if(n%3125/*5^5*/==0){
- if(n%15625/*5^6*/==0){
- ot = 6;
- }else{
- ot = 5;
- }
- }else{
- ot = 4;
- }
- }else{
- if(n%25/*5^2*/==0){
- if(n%125/*5^3*/==0){
- ot = 3;
- }else{
- ot = 2;
- }
- }else{
- ot = 1;
- }
- }
- }
- if(n>0){
- return ot + nz(n-5);
- }else{
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement