llvlleo1810

Phân tích một số thành các thừa số nguyên tố

Jul 29th, 2019
46
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. void thuasont(int n){
  4.     if(n!=0)
  5.         if(n==1) printf("1");
  6.         else{
  7.             int i=2;
  8.             while(i<=n){
  9.                 if(n%i==0){
  10.                     n/=i;
  11.                     printf("%d ", i);
  12.                 }
  13.                 else i++;
  14.             }
  15.         }
  16. }
  17.  
  18. int main(){
  19.     int n;
  20.     scanf("%d", &n);
  21.     thuasont(n);
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment