for(int r=1; r<=5; r++)
{
for(int sp=5-r; sp>0; sp--)
System.out.print(" ");
for(int c=r; c>=1; c--)
System.out.print(c);
for(int c=2; c<=r; c++)
System.out.print(c);
System.out.print("\n");
}
for(int r=1; r<=5; r++)
{
for(int sp=r; sp>=1; sp--)
System.out.print(" ");
for(int c=5-r; c>=1; c--)
System.out.print(c);
for(int c=2; c<=5-r; c++)
System.out.print(c);
System.out.print("\n");
}
the series continues with the length of odd series ie.1,3,5,7...so on.the middle integer is extra sdded in every number.it's general structure is
(inital numbers)(extra number)(reverse of initial numbers)
extra number is always multplied by 2 with last extra number added
char s[50];
s[0]=1;
for(i=1;i<n;i++)
{
traverse the array to next middle position
add the extra element in between the elements
concatenate the reverse part of initial elements
}
this can b done as
for(i=1,j=0;i<n;i=strlen(s),j++)
{
for(k=i;k>j;k--)
{
s[k+1]=s[k];
}
s[j+1]=s[j-1]*2;
s[i+3]='\0';
print s;
}
/*determine the pattern 1234321*/ #include<stdio.h> #include<conio.h> main() { int i, j; for (i=1; i<=7; i++) { if (i<5) { j=i; printf("\n %d", j); } else { j=8-i; printf("\n %d", j); } } getch() }
#include#includevoid main(){clrscr();for (int i=1;i
If you visualize 1123581321 as a set of numbers (without spaces in between) instead of one number, you'll see that it's a set of the first 8 Fibnocci nos. - 1 1 2 3 5 8 13 21. The following program would print the required no. using a For looping structure. int main (void) { int i=1; int j=1; int k, num=1; for(k=0; k<7; k++){ if(k==0){ printf("%d", num); } printf("%d", num); //next no. is the sum of previous two nos. in the series i=j; j=num; num=i+j; // 1 + 1 = 2 ... 1 + 2 = 3 ... 2 + 3 = 5 ... 3 + 5 = 8 // sum=i + j ... i takes value of j ... j takes value of sum ... repeat. } }
0
1) source program to object program 2)object program to object program output
123454321
#include <iostream> int main() { std::cout << "1 121 12321 1234321" << std::endl; return 0; }
/*determine the pattern 1234321*/ #include<stdio.h> #include<conio.h> main() { int i, j; for (i=1; i<=7; i++) { if (i<5) { j=i; printf("\n %d", j); } else { j=8-i; printf("\n %d", j); } } getch() }
1x1=1 11x11=121 111x111=12321 1111x1111=1234321 11111x11111=123454321 There is another 11 trick. 11 *11 ok so you always put the 11 on top. Then the number on the bottom. The first digit goes on the left. then leave a space for the middle number. Then the second digit and put it in the right spot. Then add those together and put that numbe rinto the middle spot! ----- 121
As the World Turns - 1956 1-12321 was released on: USA: 10 August 2004
111111111 x 111111111 = 12'345.6789876, "Hope that helps." you can get the square of any number which contain only 1, like: 11 or 11111111 with the thrick below, & of course there would be no need for any kinda calculator. 11*11=121 111*111=12321 1111*1111=1234321 got it ? just count how many times 1 has been repeated in the number, for instance in the last case it's been repeated 4 times. then simply write 1 2 3 4 3 2 1. this cutoff has no limitation in frequency of 1 in the number. & Done.
The factors of 121 are 1•121 and 11•11 :)
Total = 10000(1+i)n Total = 10000(1.2321)2 Total = 12321 Change = interest gained = 12321 - 10000 = 2321
#include#includevoid main(){clrscr();for (int i=1;i
If you visualize 1123581321 as a set of numbers (without spaces in between) instead of one number, you'll see that it's a set of the first 8 Fibnocci nos. - 1 1 2 3 5 8 13 21. The following program would print the required no. using a For looping structure. int main (void) { int i=1; int j=1; int k, num=1; for(k=0; k<7; k++){ if(k==0){ printf("%d", num); } printf("%d", num); //next no. is the sum of previous two nos. in the series i=j; j=num; num=i+j; // 1 + 1 = 2 ... 1 + 2 = 3 ... 2 + 3 = 5 ... 3 + 5 = 8 // sum=i + j ... i takes value of j ... j takes value of sum ... repeat. } }
1, 11 and 121
1, 11, 121, -1, -11, -121