import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 

public class test {
public static void main(String[] args) throws IOException {

 

BufferedReader ip = new BufferedReader(new InputStreamReader(System.in));
long a=0, b=1, c;
int n;

System.out.print("몇 번째 항까지 출력합니까? ");
n = Integer.parseInt(ip.readLine());

for(int i=1; i<=n; i++) {
c = a + b;
a = b;
b = c;
System.out.printf("%ld ",c); <-------------------------- 이부분

-----------------------------------------------------------------

 

피보나치 연습문제 풀었는데 long형이라 %ld로 했거든 근데 에러나더라구

 

Exception in thread "main" java.util.UnknownFormatConversionException: C
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.<init>(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at 1test.main(test.java:194)

 

 

이거 %d로 하면 잘 출력되는데 왜 long형에 맞게 %ld로 쓰면 에러나는거임?