Advertisement
4doorsmorehories

perfect number

Apr 16th, 2024 (edited)
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7.    
  8.  
  9.     int n,m;
  10.     scanf("%d",&n);
  11.     for(int i=2; i<n/2; i++){
  12.         m= pow(2,(i-1))*(pow(2,i)-1);
  13.         printf("%d",m);
  14.         if(m==n){
  15.             printf("Perfect Number");
  16.             return 0;
  17.         }
  18.     }
  19.     printf("Not a Perfect Number");
  20.    
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include <math.h>
  30. #include <stdlib.h>
  31.  
  32. int main() {
  33.    
  34.    
  35.  
  36.     int n,m;
  37.     scanf("%d",&n);
  38.     for(int i=2; i<n/2; i++){
  39.         m= pow(2,(i-1))*(pow(2,i)-1);
  40.         if(m==n){
  41.             printf("Perfect Number");
  42.             return 0;
  43.         }
  44.     }
  45.     printf("Not a Perfect Number");
  46.    
  47. }
  48.  
  49.  
  50.  
  51.  
  52. #include <stdio.h>
  53. #include <string.h>
  54. #include <math.h>
  55. #include <stdlib.h>
  56.  
  57. int main() {
  58.  
  59.     int n;
  60.     scanf("%d", &n);
  61.     for(int i=2; i<n/2; i++){
  62.         if(n%i == 0){
  63.             printf("Not a Prime Number");
  64.             return 0;
  65.         }
  66.     }
  67.     n!=1 ? printf("Prime Number") : printf("Not a Prime Number");;
  68. }
  69.  
  70.  
  71.  
  72. #include <stdio.h>
  73. #include <string.h>
  74. #include <math.h>
  75. #include <stdlib.h>
  76.  
  77. int main() {
  78.  
  79.     int n,i;
  80.     scanf("%d%d", &n,&i);
  81.     if(n%i==0){
  82.         printf("Smooth Number");
  83.         return 0;
  84.     }
  85.     printf("Not a Smooth Number");
  86.    
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement