size(450,400);
// 2,4..
int countEven = 0;
int countEvenDivWith5 = 0;
int countOther = 0;
int initial = 15;
textSize(20);
int xOther = 0;
int xEven = 0;
int xEven5 = 0;
for (int i=0; i <=initial; i++){
if (i%2 == 0 && i%5 == 0){
xEven5 = xEven5 + 25;
fill(0, 255, 0);
text(i, xEven5, 200);
countEvenDivWith5 = countEvenDivWith5 + 1;
xEven = xEven + 25;
fill(255, 0, 0);
text(i, xEven, 100);
countEven = countEven + 1;
} else if (i%2 == 0) {
xEven = xEven + 25;
fill(255, 0, 0);
text(i, xEven, 100);
countEven = countEven + 1;
} else {
xOther = xOther + 25;
fill(0,0,255);
text(i, xOther, 300);
countOther = countOther + 1;
}
}
fill(0);
text("With number from 0 to " + initial + ":", 25, 20);
fill(255, 0, 0);
text("The count of even numbers: " + countEven, 25, 70);
line(0, 120, width, 120);
fill(0,255,0);
text("The count of even and it is also divisible by 5: " + countEvenDivWith5, 25, 170);
line(0, 220, width, 220);
fill(0,0,255);
text("The count of other (odd) numbers: " + countOther, 25, 270);
save("activity11.png");
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}