Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- public class ite_fibonacci {
- public static int quersumme(BigInteger i)
- {
- int result=0;
- char[] temp = i.toString().toCharArray();
- for(int i2 = 0; i2 < temp.length; i2++)
- {
- result += Character.getNumericValue(temp[i2]);
- }
- return result;
- }
- public static void main(String[] agrs)
- {
- BigInteger fib_last = new BigInteger("1");
- BigInteger fib_current = new BigInteger("1");
- BigInteger fib_next = new BigInteger("0");
- boolean fib = true;
- int zahler = 2;
- while(fib)
- {
- fib_next = fib_current.add(fib_last);
- fib_last = fib_current;
- fib_current = fib_next;
- zahler++;
- if(quersumme(fib_next) > 424242)
- {
- fib = false;
- }
- }
- System.out.println(zahler);
- //448570. Fibonacci Zahl
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement