// Compiled by: S.Mahbub-Uz-Zamanm
// http://mahbubzaman.wordpress.com/
Founder(s): Thomas J. Watson Charles and Ranlett Flint Founded: June 16, 1911, Endicott, New York, U.S.
source:
// Author Shouro and Mahbub | |
// 24 February, 2014 | |
alias লিস্ট='ls' | |
alias ঢুকি='cd' | |
alias দেখ='vim' | |
alias কপি='cp' | |
alias মুছ='rm' | |
alias পুস্তিকাবানাও='mkdir' |
#!/usr/bin/env python | |
# beta | |
# Lisence Under GPL2 | |
# Author: S.Mahbub-Uz-Zaman | |
import fnmatch | |
import os | |
def count_lines(filePath): |
// Compiled by: S.Mahbub-Uz-Zamanm
// http://mahbubzaman.wordpress.com/
Founder(s): Thomas J. Watson Charles and Ranlett Flint Founded: June 16, 1911, Endicott, New York, U.S.
source:
// beta | |
// Lisence Under GPL2 | |
// Author: S.Mahbub-Uz-Zaman | |
public static String a = "test,test,test"; | |
public static String replaceWith = " and "; | |
// using StringBuffer's replace method | |
public static void replaceLastCommaSB () { | |
StringBuffer sb = new StringBuffer(a); |
/** | |
* Author S Mahbub-Uz Zaman on October 23, 2015 | |
* Lisence Under GPL2 | |
*/ | |
public static String monthNames[] = {"January", "February", "March", "April", | |
"May", "June", "July", "August", "September", "October", | |
"November", "December"}; | |
// input 17/06/1991 |
/** | |
* Author S Mahbub-Uz Zaman on November 8, 2015 | |
* Lisence Under GPL2 | |
*/ | |
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" |
A number is a prime number if that number has precisely two distinct divisors, one and itself. First ten prime numbers are
2, 3, 5, 7, 11, 13, 17, 19, 23, 29
So, if we can find that N has two divisors than it’s a prime number else not, this is actually brute force approach and the complexity is O (N). How we do that, starting from 1 to N we have check if N is divisible by 1, 2, 3, ….., N each time it divide we increment our divisor count by one and at the end we will check if the divisor count is 2 or not.
Can we do better, yes we can. Look carefully the only even prime is 2. If we add an if condition that if the number is 2 return true else false if the number is even, because other even numbers can’t not be a prime number. For even numbers the complexity becomes O (1). So what about odd numbers? How can we improve that? We can reduce the complexity for odd number O (N / 2). See we don’t need to divide by even numbers because the Number N is an odd number, so it will never be divide by an even number. So
// Author: Mahbub | |
// http://mahbubzaman.wordpress.com/2012/06/21/count-the-unique-character-in-a-string/ | |
/* | |
input | |
“aaaaaa” | |
“aaa aaa” | |
“abcdeabcde” | |
“YESyes” | |
output |
<!-- Author: Mahbub --> | |
<h1 id="prime">2</h1> | |
<p>is a prime number</p> | |
<!-- Randomly Generates primes from first 100 --> | |
<script> | |
var primes=[-1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163 ,167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541]; | |
var index = Math.floor((Math.random() * (primes.length - 1)) + 1); | |
if (index >= 1 && index <= (primes.length - 1)) | |
document.getElementById("prime").innerHTML = primes[index]; |
while testing our app Easy Recharge, Version two, i saw this weird bug.
##Information