This file contains 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
package com.mycompany.mavenproject3; | |
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.PreparedStatement; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
/** | |
* |
This file contains 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
s=0 | |
for i in range(1000): | |
if i % 3 == 0 or i % 5 == 0: | |
s+=i | |
print s |
This file contains 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
def sumDivisibleBy(n): | |
p=int(999/n) | |
return n * (p * (p + 1)) / 2 | |
s=int(sumDivisibleBy(3) + sumDivisibleBy(5) - sumDivisibleBy(15)) | |
print(s) |
This file contains 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
/** | |
* | |
* @author i88.ca | |
*/ | |
public class ProjectEuler1 { | |
public static void main(String[] args) { | |
int s = sumDivisibleBy(3) + sumDivisibleBy(5) - sumDivisibleBy(15); | |
System.out.println(s); |
This file contains 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
p,c=0,1 | |
s=0 | |
print s | |
while c<4000000: | |
print c | |
if c%2 ==0: | |
s=s+c | |
print s | |
p,c=c,p+c | |
print s |
This file contains 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
#!/usr/bin/python | |
import MySQLdb | |
conn = MySQLdb.connect (host = "host", | |
user = "us", | |
passwd = "pass", | |
db = "yourDB") | |
cursor = conn.cursor (MySQLdb.cursors.DictCursor ) | |
cursor.execute ("SELECT * from yourTable") |
This file contains 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
package euler; | |
/** | |
* @author <a href="http://i88.ca">http://i88.ca</a> | |
* | |
*/ | |
public class P2 { | |
public static void main(String[] args) { | |
int a = 1; |
This file contains 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
package euler; | |
/** | |
* @author i88.ca | |
* | |
*/ | |
public class P4 { | |
public static int reverse(int number) { | |
// reverse function of String is applicable too. |
This file contains 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
def is_palindrome(n): | |
"""Return True if n is a palindrome; False otherwise.""" | |
s = str(n) | |
return s == s[::-1] | |
from itertools import product | |
print max(x * y for x, y in product(range(1000), repeat=2) if is_palindrome(x * y)) |
This file contains 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
i=19 | |
while 1: | |
i=i+19 | |
if i%17 !=0: | |
continue | |
if i%16 !=0: | |
continue | |
if i%15 !=0: | |
continue | |
if i%14 !=0: |
OlderNewer