if (onlyPrimeNums) {
ඔය කෑල්ල අයින් කරල බැලුව ඩුප්ලිකේට් අල්ලනවද නැද්ද කියල බලන්ඩ..
වැඩ කොලා...
code ekak change karala output eka wenas wena widiha balana eka hondai. ethakota hondata therum ganna puluwan

if (onlyPrimeNums) {
ඔය කෑල්ල අයින් කරල බැලුව ඩුප්ලිකේට් අල්ලනවද නැද්ද කියල බලන්ඩ..
වැඩ කොලා...

ප්රොග්රැමින් කෝඩ්ස් බ්ලා බ්ලා දන්නේ නෑ


මාත් බං. දිරවන්නෙම නැති දෙයක්
ඒත් මේ ළඟදි ජාවා පොඩ්ඩක් තේරුම් ගන්ඩ බැලුව![]()

issara matlab nam kala. dan mathaka neaneProgramming
mokakhari ide ekak dagena code eka run karala balapan machan. umbata statement lines run wena widihen program eka therum ganna puluwan wei. asa nam try ekak diyan![]()


import java.math.BigInteger;
import java.util.LinkedHashMap;
import java.util.Map
මේවට ඔබ්ජෙක්ට් හදන්ඩ ඕනෙ නැද්ද මචං ?
අනික තමා උඹෙ ක්ලාස් එක ඇතුලෙම ඒකෙ ඔබ්ජෙක්ට් එකකුත් හදල..
ක්ල්ස් නේම් එකක් කැපිටල් වලින් නේද පටන් ගන්ඩෝන..
ටිකක් පැහැදිලි කරල දෙන්ඩ
public class powCalc {
public static void main(String[] args) {
powCalc pc = new powCalc();
import java.math.BigInteger;
import java.util.LinkedHashMap;
import java.util.Map
[COLOR="Red"]LinkedHashMap[/COLOR]<BigInteger, String> powLst = new LinkedHashMap<>();
[COLOR="red"]Map[/COLOR].Entry<[COLOR="red"]BigInteger[/COLOR]

issara matlab nam kala. dan mathaka neane![]()
uba meka google nokara hithala liwwa nam patta thamaprivate boolean isPrime(int n) { if (n > 2 && n % 2 == 0) { return false; } int top = (int) Math.sqrt+ 1; for (int i = 3; i < top; i += 2) { if (n % i == 0) { return false; } } return true; }


balnna one. stutyඋඹ මේව තනියම කොහොම ඉගෙන ගත්තද මංද..
මටනං කෝඩ්ස් දැක්කට තනියම තේරුම් ගන්ඩ බෑ..
සීන් එක හරියට පැහැදිලි කරන වීඩියෝස් බලන්ඩම ඕන..
මට ජාව වලට ආසාවක් ඇති වුණේ මේ යූටියුබ් චැනල් එකෙන්..
උපුල් ඩිපින් උඹත් මේක බලපං...
https://www.youtube.com/watch?v=T_nclkocrvw&list=PLqeCu_1ZdDl63h6YR3QsxcGOB7yDS7i3b


නෑ බන්... මම ඔය දේවල් ඉගෙන ගන්න ආසයි...
umba IT related job ekakda karanne machan dan?

<BigInteger, String>
<> දාන්නෙ ඇයි ?

හෙනයා;23240552 said:LinkedHashMap එක අස්සට දාන්න පුලුවන් values limit කරන එක..
ඔතනට අනුවනම් HashMap එකේ key එක විදිහට දෙන්න පුලුවන් BigInteger අගයක් විතරයි.. value එක විදිහට දෙන්න පුලුවන් String එකක් විතරයි.. තේරුනාද මන්ද..![]()


mport java.math.BigInteger;
import java.util.LinkedHashMap;
import java.util.Map;
public class powCalc {
public static void main(String[] args) {
powCalc pc = new powCalc();
LinkedHashMap<BigInteger, String> powLst = new LinkedHashMap<>();
LinkedHashMap<BigInteger, String> dupLst = new LinkedHashMap<>();
//variables (change this values as your requirement )
int base = 100;//max base
int power = 100;//max power
boolean onlyPrimeNums = true;//use only prime numbers or not
boolean showPow = true;//show or not output of power calc
for (int i = 2; i < base; i++) {
if (onlyPrimeNums) {
if (pc.isPrime(i)) {
for (int j = 2; j < power; j++) {
BigInteger pow = pc.pow(BigInteger.valueOf(i), BigInteger.valueOf(j));
String nb = i + "^" + j;
if (showPow) {
System.out.println(nb + " = " + pow);
}
if (powLst.containsKey(pow)) {
dupLst.put(pow, nb);
} else {
powLst.put(pow, nb);
}
}
}
} else {
for (int j = 2; j < power; j++) {
BigInteger pow = pc.pow(BigInteger.valueOf(i), BigInteger.valueOf(j));
String nb = i + "^" + j;
if (showPow) {
System.out.println(nb + " = " + pow);
}
if (powLst.containsKey(pow)) {
dupLst.put(pow, nb);
} else {
powLst.put(pow, nb);
}
}
}
}
if (dupLst.size() > 0) {
for (Map.Entry<BigInteger, String> entry : dupLst.entrySet()) {
BigInteger pow = entry.getKey();
String bas = entry.getValue();
System.out.println(powLst.get(pow) + " overlap with " + bas + "[" + pow + "]");
}
}else{
System.out.println("No value is overlapped");
}
}
private BigInteger pow(BigInteger base, BigInteger exponent) {
BigInteger result = BigInteger.ONE;
while (exponent.signum() > 0) {
if (exponent.testBit(0)) {
result = result.multiply(base);
}
base = base.multiply(base);
exponent = exponent.shiftRight(1);
}
return result;
}
private boolean isPrime(int n) {
if (n > 2 && n % 2 == 0) {
return false;
}
int top = (int) Math.sqrt+ 1;
for (int i = 3; i < top; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
}