eolymp
bolt
Try our new interface for solving problems
Problems

Number of divisors

published at 1/16/24, 1:39:01 pm

cpp:

include <iostream>

include <algorithm>

include <vector>

using namespace std;

int main() { iosbase::syncwith_stdio(0); cin.tie(0); int n; cin >> n; int cnt = 0; for(int i=1; i<=n/2; i++){ if(n%i == 0){ cnt++; } } cout << cnt+1;

return 0;

}

..

python:

import math n = int(input()) ans = 0 for i in range(1,int(math.ceil(math.sqrt(n)))): if n%i == 0: ans += 1 eded = 0 if math.ceil(math.sqrt(n))**2 == n: eded = 1 print(ans*2+eded)

published at 2/8/24, 7:52:06 pm

n=int(input()) o=0 i=2 while i<=n: if n%i==0: o+=1 i+=1 print(o+1)