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
#include <stdio.h> | |
int main(){ | |
int n; | |
int count = 0; | |
printf("n = "); | |
if(scanf("%d", &n) != 1) { | |
puts("Wrong input."); | |
return 1; | |
} | |
while(n != 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
#include <stdio.h> | |
int main(){ | |
int i; | |
float x,n; | |
float sum_x = 0.0; | |
float squared_x = 0.0; | |
float mean,variance; | |
printf("n = "); | |
scanf("%f", &n); | |
for(i=1;i<=n;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
#include <stdio.h> | |
int main(){ | |
int n,i; | |
printf("n = "); | |
scanf("%d", &n); | |
while(n != 1){ | |
for(i=2;i<=n;i++){ | |
if(n%i == 0){ | |
printf("%d ",i); | |
n /= 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
#include <stdio.h> | |
#include <math.h> | |
long fact(int n){ | |
if (n <= 1) { | |
return 1L; | |
} else { | |
return n * fact(n -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
let yen_of_doll doll = | |
let rate = 114.32 in | |
let yen = doll *. rate in | |
if (int_of_float(yen *. 10.0) mod 10) < 5 then int_of_float (yen) else int_of_float (yen+.1.0) |
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
let doll_of_yen yen = | |
let rate = 114.32 in | |
let doll = float_of_int(yen) /. rate in | |
if int_of_float(doll *. 1000.0) mod 10 < 5 then floor(doll*.100.0)/.100.0 else floor((doll+.0.01)*.100.0)/.100.0 |
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
let string_of_doll doll = | |
let rate = 114.32 in | |
let yen = doll *. rate in | |
string_of_float(doll) ^ "dollars are " ^ string_of_float(yen) ^ " yen. " |
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
let capitalize chr = | |
let ascii = int_of_char chr in | |
if ascii > 96 && ascii < 123 then char_of_int(ascii-32) else chr |
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
let f b1 b2 = if(b1 > b2 = b1 < b2) then true else false |
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
let f b1 b2 = if(b1 < b2 = b1 > b2 = false) then true else false |