import java.util.Scanner; public class LabTask3 { public static void main(String args[]) { int n1=0,n2=1,n3; Scanner sc=new Scanner(System.in); System.out.println("Enter 'k' value:"); int k=sc.nextInt(); System.out.println(n1+" "+n2); for(int i=2;i<k;i++) { n3=n1+n2; System.out.println(" "+n3); n1=n2; n2=n3; } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter