You are viewing a single comment's thread. Return to all comments →
JAva code
import java.io.*; import java.util.*; import java.math.BigInteger; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); long t = in.nextLong(); System.out.println(count(t)); } public static String count(long num) { BigInteger modulus = BigInteger.TEN.pow(10); BigInteger sum = BigInteger.ZERO; for (int i = 1; i <= num; i++) sum = sum.add(BigInteger.valueOf(i).modPow(BigInteger.valueOf(i), modulus)); return sum.mod(modulus).toString(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #48: Self powers
You are viewing a single comment's thread. Return to all comments →
JAva code