/* This program calculates the value of sigma funtion(as defined in the problem) for a given value of x and n */ public class divisor { /* This function calculates the value of kpowerm */ public static int power(int k,int m) { int i=0; int p=1; for(i=0;i<=m-1;i++) { p=p*k; } return p; } public static void main(String args[]) { int i,n,x; int sigma=0,p; x = Integer.parseInt(args[0]); n = Integer.parseInt(args[1]); System.out.println(x+" "+n); for(i=1;i<=n;i++) { if(n%i==0) { p = power(i,x); sigma = sigma + p; } } System.out.println("The value of sigma(n) is "+sigma); } }