SHARE
TWEET

Untitled

a guest Jan 24th, 2020 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int isPrime(int n)
  4. {
  5.  
  6.     if(n<2) return 0;
  7.  
  8.     for(int i=2; i*i<n; i++){
  9.         if(n%i==0) return 0;
  10.     }
  11.     return 1;
  12.  
  13. }
  14. void sieve(int n)
  15. {
  16.     int arr[n] = {0};
  17.     arr[1] = 1;
  18.     for(int i=2; i<n; i++){
  19.         if(arr[i]==0){
  20.             for(int j=i+i; j<n; j=j+i){
  21.                 arr[j] = 1;
  22.             }
  23.         }
  24.     }
  25.     for (int i=1; i<n; i++){
  26.         cout << i << " " << arr[i] << "\n";
  27.     }
  28. }
  29. void sieveDivCount(int n)
  30. {
  31.  
  32.     int arr[n] = {0};
  33.  
  34.     for(int i=1; i<=n; i++){
  35.         for(int j=i; j<n; j=j+i){
  36.             arr[j]++;
  37.         }
  38.     }
  39.     for (int i=1; i<n; i++){
  40.         cout << i << " " << arr[i] << "\n";
  41.     }
  42.  
  43. }
  44. void sieveDivSum(int n)
  45. {
  46.  
  47.     int arr[n] = {0};
  48.  
  49.     for(int i=1; i<=n; i++){
  50.         for(int j=i; j<n; j=j+i){
  51.             arr[j]+=i;
  52.         }
  53.     }
  54.     for (int i=1; i<n; i++){
  55.         cout << i << " " << arr[i] << "\n";
  56.     }
  57.  
  58. }
  59.  
  60. int main()
  61. {
  62.     int a;
  63.     cin>>a;
  64.     sieveDivSum(a);
  65.     return 0;
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top