Untitled
unknown
plain_text
4 years ago
690 B
7
Indexable
import java.math.*; import java.util.Scanner; class Main { public static int countDivisors(int n){ if (n==1) return 1; int cnt = 0; for(int i=1; i<(int)(Math.sqrt(n) + 1); i++){ if (n % i == 0) cnt += n/i; } return (int)(cnt+1); } public static void main (String[] args) { Scanner my_scan = new Scanner(System.in); int n = my_scan.nextInt(); int[] num = new int[n]; for(int i=0; i<n; i++){ num[i] = my_scan.nextInt(); } int sum = 0; for(int i=0; i<n; i++){ sum += countDivisors(num[i]); } System.out.println(sum); } }
Editor is loading...