Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.math.BigInteger;
- import java.util.ArrayList;
- import java.util.LinkedList;
- public class BEAL {
- public static ArrayList<Integer> primeFactors(int number) {
- int n = number;
- ArrayList<Integer> factors = new ArrayList<Integer>();
- for (int i = 2; i <= n; i++) {
- while (n % i == 0) {
- if (!factors.contains(i))
- factors.add(i);
- n /= i;
- }
- }
- return factors;
- }
- public static void main(String[] args) {
- LinkedList<BigInteger> broevi = new LinkedList<BigInteger>();
- BigInteger a1 = new BigInteger("1");
- BigInteger x1 = new BigInteger("3");
- File file = new File("beal.txt");
- try{
- FileWriter fw = new FileWriter(file.getAbsoluteFile());
- BufferedWriter bw = new BufferedWriter(fw);
- for(int a = 50; a<=99 ; a++){
- for(int x = 3; x <= 99 ; x++){
- a1 = new BigInteger(a+"");
- x1 = new BigInteger(x+"");
- broevi.add(a1.pow(x));
- bw.write(a + "," + x + "," + broevi.getLast());
- bw.newLine();
- }
- }
- bw.close();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- file = new File("ednakvo.txt");
- try{
- FileWriter fw = new FileWriter(file.getAbsoluteFile());
- BufferedWriter bw = new BufferedWriter(fw);
- for(int i=0;i<broevi.size();i++){
- for(int j=i+1;j<broevi.size();j++){
- for(int z=0;z<broevi.size();z++){
- System.out.println("prov: " + i + " " + j + " " + z);
- if(broevi.get(i).add(broevi.get(j)).equals(broevi.get(z))){
- bw.write(broevi.get(i) + "+" + broevi.get(j) + "=" + broevi.get(z));
- bw.newLine();
- }
- }
- }
- }
- bw.close();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement