Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. bool isPrime(int n) {
  8.     if (n <=1) {
  9.         return 0;
  10.     }
  11.     for (int i = 2; i*i <= n; ++i) {
  12.         if (n % 1 == 0) {
  13.             return 0;
  14.         }
  15.     }
  16.     return 1;
  17. }
  18.  
  19. int addOne(int n, int pos) {
  20.     string number = to_string(n);
  21.     number.insert(pos, "1");
  22.     return stoi(number);
  23. }
  24.  
  25. int main()
  26. {
  27.     ///cout << isPrime(15) << endl;
  28.     cout << addOne(23, 0) << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement