Advertisement
ambition-xx

test

Oct 11th, 2021
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<cstring>
  4. #include<vector>
  5. #include<array>
  6. #include<memory>
  7. //#include<list>
  8. //#include<stack>
  9. //#include<queue>
  10. //#include<map>
  11. //#include<set>
  12. //#include<cstdio>
  13. //#include<cstdlib>
  14. #include<algorithm>
  15. using namespace std;
  16. int f(int n){
  17.     for(int i = 1; ; i++){
  18.         if(n % i == 0) continue;
  19.         else return i;
  20.     }
  21.     return -1;
  22. }
  23. int s(int n){
  24.     int sum = 0;
  25.     for(int i = 1; i <= n; i++){
  26.         cout << "f[" << i << "]" << "=" << f(i) << endl;
  27.         sum += f(i);
  28.     }
  29.     return sum;
  30. }
  31. int main(){
  32.     //freopen("C:\\Users\\Ambition\\Desktop\\in.txt","r",stdin);
  33.     int n;
  34.     while(cin >> n){
  35.         cout << s(n) << endl;
  36.     }
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement