sivan_iut

Untitled

Feb 29th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n,k;
  6.     scanf("%d%d",&n,&k);
  7.     int c=0;
  8.     while(n!=0)
  9.     {
  10.  
  11.         n=n-1;
  12.         c++;
  13.         while(n%k==0)
  14.         {
  15.             c++;
  16.             n=n/k;
  17.          }
  18.  
  19. }
  20.     printf("%d",c);
  21.  
  22.    return 0;
  23.  
  24. }
Add Comment
Please, Sign In to add comment