prathmaka sankyawaka bal bedenne e prathmaka sankyawe bala walin witharai....
prathmaka sankyawaka bal bedenne e prathmaka sankyawe bala walin witharai....
එකෙනුත් එම සංඛ්යාවෙනුත් පමණක් බෙදෙන සංඛ්යා ප්රථමක සංඛ්යා නම් මේ.
ඒ කාලේ ගණන් පංති ඉවර උනේ රැ 8ට වගේ, මමයි අපේ පැත්තට යන තව කෙල්ලෝ 2නෙකුයි තමයි යන්නේ රෑ අම්බෝ එක කෙල්ලෙක්ගෙ කද![]()
![]()



හා මොඩිෆයි කරලම එවපං. සෝස් කෝඩ් එකත් එවන්ඩ..
හදිසියක් නෑ. හිමීට බලමු

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();
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(n) + 1;
for (int i = 3; i < top; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
menna machan Java code eka
Code: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(); 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(n) + 1; for (int i = 3; i < top; i += 2) { if (n % i == 0) { return false; } } return true; } }

menna machan Java code eka
Code: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(); 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(n) + 1; for (int i = 3; i < top; i += 2) { if (n % i == 0) { return false; } } return true; } }
97^99 න් ඉවරයිමට 2^1 ඉඳල ආවෙ නෑනෙ. 61^51 ඉඳල රිසල්ට් එක ආවෙ97^99 න් ඉවරයි

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();
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 ([COLOR="Red"]int j = 1[/COLOR]; 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 ([COLOR="red"]int j = 1[/COLOR]; 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(n) + 1;
for (int i = 3; i < top; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
machan j = 1 karanna ethakota hari
LinkedHashMap එකෙන් මොනාද බං වෙන්න

LinkedHashMap kiyanne Data Structure ekak ban. Wisheshathwe thamai api data add karana anu piliwelatama data store wenawa. api data add karapu piliwelatama apita data read akranna puluwan

අරක තාම හරිගියෙ නෑ මචං.. මම eqlipse දාගෙන ඉන්නෙ..
Java SE 8.172 කිට් එක තියෙන්නෙ
මටනං ලොකු දැනුමක් නෑ මේ ගැන
awula mama hithanne umbe output eka pennana thana ida madi wage ban.
max base eka 20k dapan, max power ekath 10k dapan. ita passe output eka balapanko.
puluwan ma, try karapan output eka txt file ekakata write karanna. Ona tharam samples thiyanawa google karapan. awulak awoth ahanna machan.
හරි ගියා
ටෙක්ස්ට් ෆයිල් එකකට ගන්නෙ කොහෙකාමද
අනික තමා පවර් එක 100ට දුන්නම නැත්තං 50ට දුන්නම එකක් අඩු වෙලා ඉවර වෙන එක
99න් ඉවර වෙනව
නැත්තං 49න් ඉවර වෙනව
for (int i = 2; i <= base; i++) {
if (onlyPrimeNums) {
if (pc.isPrime(i)) {
for (int j = 1; j <= power; j++) {
BigInteger pow = pc.pow(BigInteger.valueOf(i), BigInteger.valueOf(j));
String nb = i + "^" + j;

සමාන ලකුණ දැම්මම හරි ගියා![]()
wade allala yanne oya 
හරි ගියා
ටෙක්ස්ට් ෆයිල් එකකට ගන්නෙ කොහෙකාමද
අනික තමා පවර් එක 100ට දුන්නම නැත්තං 50ට දුන්නම එකක් අඩු වෙලා ඉවර වෙන එක
99න් ඉවර වෙනව
නැත්තං 49න් ඉවර වෙනව

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

2^2 overlap with 4^1
2^4 overlap with 16^1
2^6 overlap with 8^2
2^8 overlap with 16^2
2^10 overlap with 4^5
2^12 overlap with 16^3
2^14 overlap with 4^7
2^16 overlap with 16^4
2^18 overlap with 8^6
2^20 overlap with 16^5
2^3 overlap with 8^1
2^9 overlap with 8^3
2^15 overlap with 8^5
4^12 overlap with 16^6
4^15 overlap with 8^10
4^18 overlap with 16^9
3^2 overlap with 9^1
3^4 overlap with 9^2
3^6 overlap with 9^3
3^8 overlap with 9^4
3^10 overlap with 9^5
3^12 overlap with 9^6
3^14 overlap with 9^7
3^16 overlap with 9^8
3^18 overlap with 9^9
3^20 overlap with 9^10
4^14 overlap with 16^7
4^16 overlap with 16^8
8^16 overlap with 16^12
if (onlyPrimeNums) {
ඔය කෑල්ල අයින් කරල බැලුව ඩුප්ලිකේට් අල්ලනවද නැද්ද කියල බලන්ඩ..
වැඩ කොලා...