how do i print a letter, x times?
for example, an a repeated 6 times would be aaaaaa
how do i print a letter, x times?
for example, an a repeated 6 times would be aaaaaa
you can use a for loop
for(int i=0; i<6; i++) {
print("a");
}
println("");
or
for(int i=0; i<6; i++) {
text("a",
33+11*i, 44);
}
Double x=Double.POSITIVE_INFINITY-1;
for(int i=0; i<x; i++)
print("a");
this is kind of awesome
If you want a usable String instead of printing directly to the console, you can use StringBuffer for performance:
String s;
char c = 'a';
long x = 100; // how many times to concatenate
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < x; i++) {
buffer.append(c);
}
s = buffer.toString();
println(s);
It (almost i need one more thing) runs a program that would output the lowest number possible, itβs not possible because it would repeat 0 forever, but when im done it should place a one at the end (which once again is not possible because the 0 would repeat forever) if we ever find the highest number possible you could switch Double.POSITIVE_INFINITY-1 with that number, and boom lowest number possible
this is the complete code:
Double x=Double.POSITIVE_INFINITY-1;
int i=0;
if (i==0){
print(0.);}
for( i=0; i<x; i++)
print(0);
if (i==x){
print(1);}
this would be the output if we assumed googol as the highest number possible:
0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Only this is the for loop
The for loop ends after this line
To include more lines in the for loop use { }
Not sure what you try to achieve
Did you try println (Double.POSITIVE_INFINITY);
@Chrisir i explained what i tried to achieve here
and gave an example here
oh i see what i did wrong
here is the new version:
double x=Double.POSITIVE_INFINITY;
int i=0;
void draw(){
if (i==0){
print(0.);}
for( i=0; i<x; i++)
print(0);
if (i==x){
print(1);}}
@Chrisir i hope this makes more sense
You need { after that
This can never be true
already said that here
because the for loop only runs up to i<x
if you change the x to a non infinite number it works just fine
by the way, I think print and println are a bit buggy. Eventually they stop working