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
function palindrome(str) { | |
str = str.toLowerCase().replace(/[\w]/g, ''); | |
for(var i = 0, len = str.length - 1; i < len/2; i++) { | |
if(str[i] !== str[len-i]) { | |
return false; | |
} | |
} | |
return true; | |
} | |
palindrome("ey_e"); |
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
class Main { | |
public static void main(String[] args) { | |
for(int i=2; i<100; i++){ | |
int count = 1; | |
for(int j=2; j<i; j++){ | |
if(i%j==0){ | |
count = 0; | |
break; | |
} | |
} |
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
class Main { | |
public static void main(String[] args) { | |
int a = 3, b = 6, c = 11, d = 10, e; | |
e = a>b ? (a>c ? (a>d ? a:d):(c>d ? c:d)):(b>c ? (b>d? b:d):(c>d ? c:d)); | |
System.out.println("Largest Number = " + e); | |
} | |
} |
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
class Main { | |
public static void main(String[] args) { | |
int a = 3, b = 6, c = 11, d = 10, e; | |
e = a>b ? (a>c ? (a>d ? a:d):(c>d ? c:d)):(b>c ? (b>d? b:d):(c>d ? c:d)); | |
System.out.println("Largest Number = " + e); | |
} | |
} |
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
#include "stdio.h" | |
int main(void) { | |
int i, num, fac = 1; | |
printf("Enter Number To find Factorial : "); | |
scanf("%d", &num); | |
for(i=1; i<=num; i++){ | |
fac *=i; | |
} | |
printf("Factorial = %d", fac); |
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
private sub Command1_click() | |
dim i as integer | |
for i = 1 to 100 | |
if i mod 7 = 0 and i mod 5 <> 0 then | |
print i | |
end if | |
Next | |
End Sub |
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
// Replace all VOWEL to EXCLAMATION | |
function vowelReplace(str){ | |
// here we define vowel | |
var myStr = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']; | |
// here we convert string to array | |
var arr = str.split('') | |
// first loop start |
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
function findNextSquare(sq){ | |
for(var i = 1; i<=sq; i++){ | |
if(i * i == sq){ | |
i++; | |
return i*i; | |
} | |
} | |
return -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
#include "stdio.h" | |
int main(void) { | |
int i = 1, j = 100; | |
while(j){ | |
printf("%d ", i); | |
i++; | |
j--; | |
} | |
} |
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
function palindrome(str){ | |
// assign a front and back pointer | |
let front = 0; | |
let back = str.length - 1; | |
//back and front pointers won't always meet in the middle, so use (back > front) | |
while(back > front){ | |
while(str[front].match(/[\W_]/)){ | |
//increments front pointer if current character doesn't meet criteria | |
front++; |
OlderNewer