Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Langzeitarithmetik
- {
- public static int[] zweimal(int zahl[])
- {
- for(int i=19; i>-1; i--)
- {
- zahl[i] = zahl[i] * 2;
- zahl[i+1] = zahl[i+1] + zahl[i] / 10;
- zahl[i] = zahl[i] % 10;
- }
- return zahl;
- }
- public static int[] zahlPlus(int zahl[], int gesamtZahl[])
- {
- for(int i=19; i>-1; i--)
- {
- gesamtZahl[i] += zahl[i];
- gesamtZahl[i+1] = gesamtZahl[i+1] + gesamtZahl[i] / 10;
- gesamtZahl[i] = gesamtZahl[i] % 10;
- }
- return gesamtZahl;
- }
- public static void main(String args[])
- {
- int zahl[] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- int gesamtZahl[] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- for(int i=0; i<63; i++)
- {
- zahl = zweimal(zahl);
- gesamtZahl = zahlPlus(zahl, gesamtZahl);
- }
- for (int i=20; i>-1; i--)
- {
- System.out.print("" + gesamtZahl[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement