# Continued Fractions Applied to the One Line Factoring Algorithm for Breaking RSA
## 5 Practical Implementation and Observations  
In this section, we provide a practical implementation of our factorization approach using continued fractions and discuss our observations based on our experiment conducted with large integers. We note that brute force searching is feasible only for smaller integers. As reported in the literature, brute force methods are usually time-consuming and hence may not be efficient for many real-time applications [50, 51]. Also, for large numbers, the \(k\) method may not be optimal. However, for all RSA numbers whose factorizations are known, a key observation provided in this paper shows that there is a relationship between the length of the continued fraction and the position where the first suitable \(k\) value appears. Further, all congruencies after this first \(k\) value are also valid \(k\) solutions. Exploring this relationship significantly reduces the search field for \(k=4 pq\). More experimental exploration in this direction is an area of our ongoing research. We provide a three-step algorithm below and the practical implementation along with the source code in the Java programming language. The Java code illustrates the simplicity of the practical implementation of our algorithm and the potential to further develop applications in information security. Firstly, we present how the continued fraction is generated using the ratio of a known \(\frac{p}{Q}\). We then use this set of convergences to create each convergence \(p/q\). From this we then determine \(k:\ k=4 pq\). We recall \(Y^{2}=\left(\lceil\sqrt{4 pqN}\rceil\right)^{2}-4 pqN\). An explanation of the three steps in the algorithm and the Java code of the implementation are provided below. Step 1: Obtain the continued fraction using the factorization of \(N:\ N=PQ\). An implementation of this step in the Java programming language was developed to practically demonstrate our simple approach. The continued fraction is returned as shown in the code snippet of our implementation in Java:  
```
publicstaticBigInteger[]ContinuedFraction(BigInteger[]R){  BigInteger[]ConFrac=newBigInteger[1000]; BigIntegerNMER=R[0],DENOM=R[1]; inti=0; while(! (DENOM.equals(BigInteger._ONE))){  R=NUMER.divideAndRemainder(DENOM); ConFrac[i]=R[0]; NUMER=DENOM; DENOM=R[1];i++; } ConFrac[i]=NUMER; returnConfrac; }
```  
Step 2: For a specified number of convergence terms, calculate the convergence. The implementation in Java was developed as follows and the convergence fraction is returned. ```
publicstaticBigInteger[]GetRatio(BigInteger[]ContinuedFraction,intSeriesLength){ BigInteger[]RATIO=newBigInteger[2]; BigIntegerRATIO2,NUMERATOR=BigInteger._ONE,DENOMINATOR; RATIO[1]=BigInteger._ONE; DENOMINATOR=ContinuedFraction[SeriesLength]; for(inti=SeriesLength;i>0;i-. ){ RATIO2=DENOMINATOR; RATIO[1]=NUMERATOR; RATIO[0]=ContinuedFraction[i-1]; NUMERATOR=RATIO2; DENOMINATOR=RATIO2.multiply(RATIO[0]).add(RATIO[1]); } RATIO[0]=DENOMINATOR; RATIO[1]=NUMERATOR; returnRATIO; }
```  
Step 3: Test the convergence and see if this is a solution for which \(k:k=4 pq\) that solves \(Y^{2}=\left(\lceil\sqrt{4 pqN}\rceil\right)^{2}-4 pqN\). The Java implementation of the logic is provided below and the result is presented as \([k,x,y,z]\).