This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrimeTest | |
{ | |
public static void main(String[] args) | |
{ | |
PrintPrimeFactors myObject = new PrintPrimeFactors(); | |
myObject.primeFactors(600851475143L); | |
} | |
} | |
public class PrintPrimeFactors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Brute Force | |
public class LargestPalindrome | |
{ | |
public static void main(String[] args) | |
{ | |
MaxPalindrome myObject = new MaxPalindrome(); | |
int maxPal = myObject.findLargestPalindromeThreeDigits(); | |
System.out.println(String.format("Max Product: %-4d", maxPal)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LowestCommonMultiple | |
{ | |
public static void main(String[] args) | |
{ | |
FindMultiple(); | |
} | |
static long FindLcm(long a,long b){ | |
long lcm,hcf = 0; | |
long i=1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DifferenceOfSquares | |
{ | |
public static void main(String[] args) | |
{ | |
long sumOfSquares = 0; | |
long squareOfSums = 0; | |
long difference = 0; | |
for (long i = 1; i <= 100; i++){ | |
sumOfSquares += i * i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrintPrimes | |
{ | |
public static void main(String[] args) | |
{ | |
int count = 1; | |
System.out.print(String.format("%-8d", 2)); | |
for (int i = 3; count < 1000; i+=2){ | |
if (isPrime(i)){ | |
System.out.print(String.format("%-8d", i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.Math; | |
public class Program{ | |
public static void main(String[] args) | |
{ | |
int n = 1000; | |
int upperLimit = approximateNthPrime(n); | |
Boolean[] flags = new Boolean[upperLimit + 1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LargestProductThirteen{ | |
public static void main( String[] args ) { | |
final String num = "731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749303589072962904915604407723907138105158593079608667017242712188399879790879227492190169972088809377665727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474821663704844031998900088952434506585412275886668811642717147992444292823086346567481391912316282458617866458359124566529476545682848912883142607690042242190226710556263211111093705442175069416589604080719840385096245544436298123098787992724428490918884580156166097919133875499200524063689912560717606058861164671094050 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Problem_11 { | |
public static void main(String [] args){ | |
int Grid [][] = { | |
{8,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,8}, | |
{49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00}, | |
{81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65}, | |
{52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91}, | |
{22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80}, | |
{24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50}, | |
{32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LongestPalindrome | |
{ | |
public static void main(String[] args) | |
{ | |
String str = longestPalindrome("bananaaabjklaskdjfaldsfhalksjf"); | |
System.out.println("Longest Anagram: " + str); | |
} | |
public static String longestPalindrome(String s) { | |
int n = s.length(); |